docstr: Save given tensors for a future call to :func:`~Function.jvp`.
  
  ``save_for_forward`` should be only called once, from inside the :func:`forward`
  method, and only be called with tensors.
  
  In :func:`jvp`, saved objects can be accessed through the :attr:`saved_tensors`
  attribute.
  
  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: +SKIP
      >>> class Func(torch.autograd.Function):
      >>>     @staticmethod
      >>>     def forward(ctx, x: torch.Tensor, y: torch.Tensor, z: int):
      >>>         ctx.save_for_backward(x, y)
      >>>         ctx.save_for_forward(x, y)
      >>>         ctx.z = z
      >>>         return x * y * z
      >>>
      >>>     @staticmethod
      >>>     def jvp(ctx, x_t, y_t, _):
      >>>         x, y = ctx.saved_tensors
      >>>         z = ctx.z
      >>>         return z * (y * x_t + x * y_t)
      >>>
      >>>     @staticmethod
      >>>     def vjp(ctx, grad_out):
      >>>         x, y = ctx.saved_tensors
      >>>         z = ctx.z
      >>>         return z * grad_out * y, z * grad_out * x, None
      >>>
      >>>     a = torch.tensor(1., requires_grad=True, dtype=torch.double)
      >>>     t = torch.tensor(1., dtype=torch.double)
      >>>     b = torch.tensor(2., requires_grad=True, dtype=torch.double)
      >>>     c = 4
      >>>
      >>>     with fwAD.dual_level():
      >>>         a_dual = fwAD.make_dual(a, t)
      >>>         d = Func.apply(a_dual, b, c)
docstr_tok: ["Save","given","tensors","for","a","future","call","to",":","func",":","`","~Function.jvp","`",".","``","save_for_forward","``","should","be","only","called","once",",","from","inside","the",":","func",":","`","forward","`","method",",","and","only","be","called","with","tensors",".","In",":","func",":","`","jvp","`",",","saved","objects","can","be","accessed","through","the",":","attr",":","`","saved_tensors","`","attribute",".","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",":","+SKIP",">",">",">","class","Func","(","torch.autograd.Function",")",":",">",">",">","@","staticmethod",">",">",">","def","forward","(","ctx",",","x",":","torch.Tensor",",","y",":","torch.Tensor",",","z",":","int",")",":",">",">",">","ctx.save_for_backward","(","x",",","y",")",">",">",">","ctx.save_for_forward","(","x",",","y",")",">",">",">","ctx.z","=","z",">",">",">","return","x","*","y","*","z",">",">",">",">",">",">","@","staticmethod",">",">",">","def","jvp","(","ctx",",","x_t",",","y_t",",","_",")",":",">",">",">","x",",","y","=","ctx.saved_tensors",">",">",">","z","=","ctx.z",">",">",">","return","z","*","(","y","*","x_t","+","x","*","y_t",")",">",">",">",">",">",">","@","staticmethod",">",">",">","def","vjp","(","ctx",",","grad_out",")",":",">",">",">","x",",","y","=","ctx.saved_tensors",">",">",">","z","=","ctx.z",">",">",">","return","z","*","grad_out","*","y",",","z","*","grad_out","*","x",",","None",">",">",">",">",">",">","a","=","torch.tensor","(","1.",",","requires_grad=True",",","dtype=torch.double",")",">",">",">","t","=","torch.tensor","(","1.",",","dtype=torch.double",")",">",">",">","b","=","torch.tensor","(","2.",",","requires_grad=True",",","dtype=torch.double",")",">",">",">","c","=","4",">",">",">",">",">",">","with","fwAD.dual_level","(",")",":",">",">",">","a_dual","=","fwAD.make_dual","(","a",",","t",")",">",">",">","d","=","Func.apply","(","a_dual",",","b",",","c",")"]
code: def save_for_forward(self, *tensors: torch.Tensor):
      r"""Save given tensors for a future call to :func:`~Function.jvp`.
  
      ``save_for_forward`` should be only called once, from inside the :func:`forward`
      method, and only be called with tensors.
  
      In :func:`jvp`, saved objects can be accessed through the :attr:`saved_tensors`
      attribute.
  
      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: +SKIP
          >>> class Func(torch.autograd.Function):
          >>>     @staticmethod
          >>>     def forward(ctx, x: torch.Tensor, y: torch.Tensor, z: int):
          >>>         ctx.save_for_backward(x, y)
          >>>         ctx.save_for_forward(x, y)
          >>>         ctx.z = z
          >>>         return x * y * z
          >>>
          >>>     @staticmethod
          >>>     def jvp(ctx, x_t, y_t, _):
          >>>         x, y = ctx.saved_tensors
          >>>         z = ctx.z
          >>>         return z * (y * x_t + x * y_t)
          >>>
          >>>     @staticmethod
          >>>     def vjp(ctx, grad_out):
          >>>         x, y = ctx.saved_tensors
          >>>         z = ctx.z
          >>>         return z * grad_out * y, z * grad_out * x, None
          >>>
          >>>     a = torch.tensor(1., requires_grad=True, dtype=torch.double)
          >>>     t = torch.tensor(1., dtype=torch.double)
          >>>     b = torch.tensor(2., requires_grad=True, dtype=torch.double)
          >>>     c = 4
          >>>
          >>>     with fwAD.dual_level():
          >>>         a_dual = fwAD.make_dual(a, t)
          >>>         d = Func.apply(a_dual, b, c)
  
      """
      for tensor in tensors:
          assert isinstance(tensor, torch.Tensor) or tensor is None, (
              "save_for_forward expects all arguments to be tensors; you should "
              "save non-tensors as attributes on ctx."
          )
  
      self.saved_for_forward = 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 2 for calling the FunctionCtx obj's underlying member method code with example usage: obj.save_for_forward() without return types