Hi,
As you can see in the warning message, it is because you call .grad on a Tensor that is not a leaf (meaning that it has some gradient history). And because it is not a leaf, the backward call won’t populate it’s .grad field so your code should most likely not be doing that.
In your example, a is a leaf and so will have a .grad field.
If you need the gradient for b, you need to set b.retain_grad() as mentioned in the warning.