You’ll find the gradient by looking at y.grad. Usually this isn’t saved though, so take a look here:
y.grad
If you want to specifically use a hook, then you can register a closure as a hook and that will save the gradient, As was done here: