albanD:

So it is expected that loss.grad is None


I get your point @albanD
But the magnitude of loss from the above loss function increases when I update lambda1 and lambda2 (as mentioned in the paper) and does not go down. I conclude from this that the model parameters are not updating. So, either there is an error in calculating gradients during backpropagation or there is an error in updating model parameters. I am not able to pinpoint the issue.