Hi,
Your hook can return a new Tensor that will then be used instead of the given Tensor.
Note that hooks should never modify their input inplace. So you can do:
def my_hook(grad):
    grad = grad.clone()
    grad[0][0] = 50
    print("new grad: ", grad)
    return grad

And register that as a hook for out1