tensor.backward() doesn’t return anything, it sets/updates the .grad attribute on the autograd leaves.
If you want gradients to be returned instead of accumulated in .grad, you would want to use torch.autograd.grad.
Best regards
Thomas