Hi,
You might want to double check the register_backward_hook() doc. But it is known to be kind of broken at the moment and can have this behavior.
I would recommend you use autograd.grad() for this though. That will make it simpler than backward+access to the .grad field.