docstr: Save given tensors for a future call to :func:`~Function.backward`.
  
  ``save_for_backward`` should be called at most once, only from inside the
  :func:`forward` method, and only with tensors.
  
  All tensors intended to be used in the backward pass should be saved
  with ``save_for_backward`` (as opposed to directly on ``ctx``) to prevent
  incorrect gradients and memory leaks, and enable the application of saved
  tensor hooks. See :class:`torch.autograd.graph.saved_tensors_hooks`.
  
  Note that if intermediary tensors, tensors that are neither inputs
  nor outputs of :func:`forward`, are saved for backward, your custom Function
  may not support double backward.
  Custom Functions that do not support double backward should decorate their
  :func:`backward` method with ``@once_differentiable`` so that performing
  double backward raises an error. If you'd like to support double backward,
  you can either recompute intermediaries based on the inputs during backward
  or return the intermediaries as the outputs of the custom Function. See the
  `double backward tutorial <https://pytorch.org/tutorials/intermediate/custom_function_double_backward_tutorial.html>`_
  for more details.
  
  In :func:`backward`, saved tensors can be accessed through the :attr:`saved_tensors`
  attribute. Before returning them to the user, a check is made to ensure
  they weren't used in any in-place operation that modified their content.
  
  Arguments can also be ``None``. This is a no-op.
  
  See :ref:`extending-autograd` for more details on how to use this method.
  
  Example::
      >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_AUTOGRAD)
      >>> class Func(Function):
      >>>     @staticmethod
      >>>     def forward(ctx, x: torch.Tensor, y: torch.Tensor, z: int):
      >>>         w = x * z
      >>>         out = x * y + y * z + w * y
      >>>         ctx.save_for_backward(x, y, w, out)
      >>>         ctx.z = z  # z is not a tensor
      >>>         return out
      >>>
      >>>     @staticmethod
      >>>     @once_differentiable
      >>>     def backward(ctx, grad_out):
      >>>         x, y, w, out = ctx.saved_tensors
      >>>         z = ctx.z
      >>>         gx = grad_out * (y + y * z)
      >>>         gy = grad_out * (x + z + w)
      >>>         gz = None
      >>>         return gx, gy, gz
      >>>
      >>> a = torch.tensor(1., requires_grad=True, dtype=torch.double)
      >>> b = torch.tensor(2., requires_grad=True, dtype=torch.double)
      >>> c = 4
      >>> d = Func.apply(a, b, c)
docstr_tok: ["Save","given","tensors","for","a","future","call","to",":","func",":","`","~Function.backward","`",".","``","save_for_backward","``","should","be","called","at","most","once",",","only","from","inside","the",":","func",":","`","forward","`","method",",","and","only","with","tensors",".","All","tensors","intended","to","be","used","in","the","backward","pass","should","be","saved","with","``","save_for_backward","``","(","as","opposed","to","directly","on","``","ctx","``",")","to","prevent","incorrect","gradients","and","memory","leaks",",","and","enable","the","application","of","saved","tensor","hooks",".","See",":","class",":","`","torch.autograd.graph.saved_tensors_hooks","`",".","Note","that","if","intermediary","tensors",",","tensors","that","are","neither","inputs","nor","outputs","of",":","func",":","`","forward","`",",","are","saved","for","backward",",","your","custom","Function","may","not","support","double","backward",".","Custom","Functions","that","do","not","support","double","backward","should","decorate","their",":","func",":","`","backward","`","method","with","``","@","once_differentiable","``","so","that","performing","double","backward","raises","an","error",".","If","you","'d","like","to","support","double","backward",",","you","can","either","recompute","intermediaries","based","on","the","inputs","during","backward","or","return","the","intermediaries","as","the","outputs","of","the","custom","Function",".","See","the","`","double","backward","tutorial","<","https",":","\/\/pytorch.org\/tutorials\/intermediate\/custom_function_double_backward_tutorial.html",">","`","_","for","more","details",".","In",":","func",":","`","backward","`",",","saved","tensors","can","be","accessed","through","the",":","attr",":","`","saved_tensors","`","attribute",".","Before","returning","them","to","the","user",",","a","check","is","made","to","ensure","they","were","n't","used","in","any","in-place","operation","that","modified","their","content",".","Arguments","can","also","be","``","None","``",".","This","is","a","no-op",".","See",":","ref",":","`","extending-autograd","`","for","more","details","on","how","to","use","this","method",".","Example",":",":",">",">",">","#","xdoctest",":","+REQUIRES","(","env",":","TORCH_DOCTEST_AUTOGRAD",")",">",">",">","class","Func","(","Function",")",":",">",">",">","@","staticmethod",">",">",">","def","forward","(","ctx",",","x",":","torch.Tensor",",","y",":","torch.Tensor",",","z",":","int",")",":",">",">",">","w","=","x","*","z",">",">",">","out","=","x","*","y","+","y","*","z","+","w","*","y",">",">",">","ctx.save_for_backward","(","x",",","y",",","w",",","out",")",">",">",">","ctx.z","=","z","#","z","is","not","a","tensor",">",">",">","return","out",">",">",">",">",">",">","@","staticmethod",">",">",">","@","once_differentiable",">",">",">","def","backward","(","ctx",",","grad_out",")",":",">",">",">","x",",","y",",","w",",","out","=","ctx.saved_tensors",">",">",">","z","=","ctx.z",">",">",">","gx","=","grad_out","*","(","y","+","y","*","z",")",">",">",">","gy","=","grad_out","*","(","x","+","z","+","w",")",">",">",">","gz","=","None",">",">",">","return","gx",",","gy",",","gz",">",">",">",">",">",">","a","=","torch.tensor","(","1.",",","requires_grad=True",",","dtype=torch.double",")",">",">",">","b","=","torch.tensor","(","2.",",","requires_grad=True",",","dtype=torch.double",")",">",">",">","c","=","4",">",">",">","d","=","Func.apply","(","a",",","b",",","c",")"]
code: def save_for_backward(self, *tensors: torch.Tensor):
      r"""Save given tensors for a future call to :func:`~Function.backward`.
  
      ``save_for_backward`` should be called at most once, only from inside the
      :func:`forward` method, and only with tensors.
  
      All tensors intended to be used in the backward pass should be saved
      with ``save_for_backward`` (as opposed to directly on ``ctx``) to prevent
      incorrect gradients and memory leaks, and enable the application of saved
      tensor hooks. See :class:`torch.autograd.graph.saved_tensors_hooks`.
  
      Note that if intermediary tensors, tensors that are neither inputs
      nor outputs of :func:`forward`, are saved for backward, your custom Function
      may not support double backward.
      Custom Functions that do not support double backward should decorate their
      :func:`backward` method with ``@once_differentiable`` so that performing
      double backward raises an error. If you'd like to support double backward,
      you can either recompute intermediaries based on the inputs during backward
      or return the intermediaries as the outputs of the custom Function. See the
      `double backward tutorial <https://pytorch.org/tutorials/intermediate/custom_function_double_backward_tutorial.html>`_
      for more details.
  
      In :func:`backward`, saved tensors can be accessed through the :attr:`saved_tensors`
      attribute. Before returning them to the user, a check is made to ensure
      they weren't used in any in-place operation that modified their content.
  
      Arguments can also be ``None``. This is a no-op.
  
      See :ref:`extending-autograd` for more details on how to use this method.
  
      Example::
          >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_AUTOGRAD)
          >>> class Func(Function):
          >>>     @staticmethod
          >>>     def forward(ctx, x: torch.Tensor, y: torch.Tensor, z: int):
          >>>         w = x * z
          >>>         out = x * y + y * z + w * y
          >>>         ctx.save_for_backward(x, y, w, out)
          >>>         ctx.z = z  # z is not a tensor
          >>>         return out
          >>>
          >>>     @staticmethod
          >>>     @once_differentiable
          >>>     def backward(ctx, grad_out):
          >>>         x, y, w, out = ctx.saved_tensors
          >>>         z = ctx.z
          >>>         gx = grad_out * (y + y * z)
          >>>         gy = grad_out * (x + z + w)
          >>>         gz = None
          >>>         return gx, gy, gz
          >>>
          >>> a = torch.tensor(1., requires_grad=True, dtype=torch.double)
          >>> b = torch.tensor(2., requires_grad=True, dtype=torch.double)
          >>> c = 4
          >>> d = Func.apply(a, b, c)
  
      """
      self.to_save = tensors
  
imports: import functools
  import inspect
  import itertools
  import warnings
  from collections import OrderedDict
  from typing import Any, List, Optional, Tuple
  import torch
  import torch._C
  import torch._functorch
  import torch.utils.hooks
  from torch._C import _functions
  from torch._functorch.autograd_function import custom_function_call
label_desc: Use image node_id 1 for calling the FunctionCtx obj's underlying member method code with example usage: obj.save_for_backward() without return types