Gradient function in linear regression

in gradient function of linear regression, can i return just the grad(gradient), instead of returning grad/m(no. of rows) or not?

Actually if you don’t divide gradients by m after calculating them, then the value of gradients will be quite high.
And now when you will update your weights, then weights will be updated by a much bigger value and thus it may result in increase in loss which should not be the case.
At last you should divide them by m after calculating them, and so that your gradient descend work fine.
Hope this cleared your doubt.