


handle = b.grad_fn.register_hook(lambda gI, gO: (gO[0] * 2,))
      >>> b.sum().backward(retain_graph=True)
      >>> print(a.grad)
      tensor([2., 2., 2.])
      >>> handle.remove() # Removes the hook
      >>> a.grad = None
      >>> b.sum().backward(retain_graph=True)
      >>> print(a.grad)
      tensor([1., 1., 1.])



Return type:
      RemovableHandle