


    ctx.set_materialize_grads(False)
  >>>         ctx.save_for_backward(x)
  >>>         return x.clone(), x.clone()
  >>>
  >>>     @staticmethod
  >>>     @once_differentiable
  >>>     def backward(ctx, g1, g2):
  >>>         x, = ctx.saved_tensors
  >>>         grad_input = torch.zeros_like(x)
  >>>         if g1 is not None:  # We must check for None now
  >>>             grad_input += g1
  >>>         if g2 is not None:
  >>>             grad_input += g2
  >>>         return grad_input
  >>>
  >>> a = torch.tensor(1., requires_grad=True)
  >>> b, _ = Func.apply(a)  # induces g2 to be undefined



