Youyoun:

but even while defining param = torch.tensor(1., required_grad=True), param.grad is still equal to nan.


that’s because of derivative d(a*p)/dp=a=nan, this is computed elementwise after broadcasting