class_docstr: Base class to create custom `autograd.Function`.
  
  To create a custom `autograd.Function`, subclass this class and implement
  the :meth:`forward` and :meth:`backward` static methods. Then, to use your custom
  op in the forward pass, call the class method ``apply``. Do not call
  :meth:`forward` directly.
  
  To ensure correctness and best performance, make sure you are calling the
  correct methods on ``ctx`` and validating your backward function using
  :func:`torch.autograd.gradcheck`.
  
  See :ref:`extending-autograd` for more details on how to use this class.
  
  Examples::
  
      >>> # xdoctest: +REQUIRES(env:TORCH_DOCTEST_AUTOGRAD)
      >>> class Exp(Function):
      >>>     @staticmethod
      >>>     def forward(ctx, i):
      >>>         result = i.exp()
      >>>         ctx.save_for_backward(result)
      >>>         return result
      >>>
      >>>     @staticmethod
      >>>     def backward(ctx, grad_output):
      >>>         result, = ctx.saved_tensors
      >>>         return grad_output * result
      >>>
      >>> # Use it by calling the apply method:
      >>> # xdoctest: +SKIP
      >>> output = Exp.apply(input)
class_docstr_tok: ["Base","class","to","create","custom","`","autograd.Function","`",".","To","create","a","custom","`","autograd.Function","`",",","subclass","this","class","and","implement","the",":","meth",":","`","forward","`","and",":","meth",":","`","backward","`","static","methods",".","Then",",","to","use","your","custom","op","in","the","forward","pass",",","call","the","class","method","``","apply","``",".","Do","not","call",":","meth",":","`","forward","`","directly",".","To","ensure","correctness","and","best","performance",",","make","sure","you","are","calling","the","correct","methods","on","``","ctx","``","and","validating","your","backward","function","using",":","func",":","`","torch.autograd.gradcheck","`",".","See",":","ref",":","`","extending-autograd","`","for","more","details","on","how","to","use","this","class",".","Examples",":",":",">",">",">","#","xdoctest",":","+REQUIRES","(","env",":","TORCH_DOCTEST_AUTOGRAD",")",">",">",">","class","Exp","(","Function",")",":",">",">",">","@","staticmethod",">",">",">","def","forward","(","ctx",",","i",")",":",">",">",">","result","=","i.exp","(",")",">",">",">","ctx.save_for_backward","(","result",")",">",">",">","return","result",">",">",">",">",">",">","@","staticmethod",">",">",">","def","backward","(","ctx",",","grad_output",")",":",">",">",">","result",",","=","ctx.saved_tensors",">",">",">","return","grad_output","*","result",">",">",">",">",">",">","#","Use","it","by","calling","the","apply","method",":",">",">",">","#","xdoctest",":","+SKIP",">",">",">","output","=","Exp.apply","(","input",")"]
code: def __init__(self, *args, **kwargs):
      cls = self.__class__
      warnings.warn(
          f"{cls} should not be instantiated. Methods on autograd functions"
          "are all static, so you should invoke them on the class itself. "
          "Instantiating an autograd function will raise an "
          "error in a future version of PyTorch.",
          DeprecationWarning,
      )
  
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 to create a new Function object from inherited base classes: _SingleLevelFunction with example: obj = Function()