Solved by albanD in post #2 
              
              
                Hi, 
register_backward_hook can have some unexpected behaviours sometime. 
If you want the gradient wrt an input, your can call register_hook on this input tensor directly that will be called with the gradient for this input.