Hi,
Thanks for the response. I got a little bit confused on torch.autograd.grad  and torch.autograd.backward. So for a given y = f(x), torch.autograd.grad  returns dy/dx.  For torch.autograd.backward, based on my understanding, torch.autograd.backward uses the  chain rule to calculate the gradient. However, I am not very clear about what torch.autograd.backward returns ?  If possible, I wonder if you could provide some hints for the difference between these two.
Thank you in advance!