Every time you do z = foo(z) in your RNN, you most likely create a new Tensor that is then assigned with the python variable named z. But the original Tensor contained in z and the new one have nothing in common. So if you add a hook to the second one, you won’t get gradient for the first one.
This comment refers to the case where you call .bakward() multiple times.