Hi,
x.register_hook(your_fn) will add a hook. And when the gradient for x is computed, your_fn will be called with the gradient that was computed for x.
So then from that function you can do what you want with the gradient (like storing it in a global state to access it later).
You can check the doc for register hook, but what it returns is a handle to be able to remove the hook that’s it.
To access modules in a Sequential, you can index it like any other list: mod[0], mod[1], etc/