class_docstr: Function node of the computational graph.
  
  FunctionNode is a class representing a node in a computational graph. The
  node corresponds to an application of a differentiable function to input
  variables.
  
  When a differentiable function is applied to :class:`~chainer.Variable`
  objects,
  it creates an instance of FunctionNode implementation and calls its
  :meth:`apply` method. The :meth:`apply` method basically does the following
  three things.
  
  1. Adding an edge from the function node to the variable node corresponding
     to each input. The node of each input is extracted by
     :attr:`Variable.node <chainer.Variable.node>`.
  2. Computing the output arrays of the function.
  3. Creating a :class:`~chainer.Variable` object for each output array and
     adding an edge from the node of the variable to the function node.
  
  The output variables are then returned.
  
  .. admonition:: Example
  
     Let ``x`` be an instance of :class:`~chainer.Variable` and ``f`` be an
     instance of :class:`FunctionNode` taking only one argument.
     Then the following code
  
     >>> import numpy, chainer
     >>> x = chainer.Variable(numpy.zeros(10))
     >>> f = chainer.functions.math.identity.Identity()
     >>> y = f.apply((x,))[0]
  
     computes a new variable ``y`` and creates backward references. The
     backward references are actually set as per the following diagram::
  
         x.node <--- f <--- y.node
  
     If an application of another function ``g`` occurs as
  
     >>> g = chainer.functions.math.identity.Identity()
     >>> z = g.apply((x,))[0]
  
     then the graph grows with a branch::
  
                  |--- f <--- y.node
         x.node <-+
                  |--- g <--- z.node
  
     Note that the branching is correctly managed on backward computation,
     i.e. the gradients from ``f`` and ``g`` are accumulated to the gradient
     of ``x``.
  
  Every function-node implementation should provide :meth:`forward` and
  :meth:`backward`. Instead of overriding :meth:`forward`, one can also
  implement :meth:`forward_cpu` and :meth:`forward_gpu` when the
  implementations for CPU and GPU arrays are totally different.
  
  Note that the input and output variables are inaccessible from
  :meth:`backward` by default. If it needs accesses to these variables, the
  :meth:`forward` method (or its CPU/GPU variants) has to call
  :meth:`retain_inputs` and :meth:`retain_outputs` appropriately. The
  retained input/output variables can be accessed from :meth:`backward` by
  calling :meth:`get_retained_inputs` and :meth:`get_retained_outputs`.
  
  .. note::
  
     There are two types of differentiable functions in Chainer (since v3).
     The first type is of a function using a subclass of
     :class:`~chainer.Function`,
     which is called *old-style differentiable function*. The second type is
     of a function using a subclass of :class:`FunctionNode`, which is called
     **new-style differentiable function**. There are several advantages on
     using the new-style differentiable function.
  
     - The new-style differentiable function supports *differentiable
       backpropagation*. The backpropagated gradients computed through the
       new-style differentiable functions themselves support further
       backpropagations so that the automatic higher-order differentiation is
       available.
     - The backpropagation of the new-style differentiable function can be
       more computationally efficient because the interface allows an
       implementation to omit the computation of unneeded input gradients.
  
     Note that the new-style differentiable function is the standard way of
     defining a function node of the computational graph in Chainer; old-
     style differentiable functions are implemented as wrappers of the new-
     style differentiable functions.
  
  Attributes:
      ~FunctionNode.inputs: A tuple of the input
          :class:`~chainer.variable.VariableNode` objects.
      ~FunctionNode.outputs: A tuple of weak references to the output
          :class:`~chainer.variable.VariableNode` objects.
      ~FunctionNode.rank (int): An ordinal following the topological order
          of the computational graph.
      ~FunctionNode.stack: Stack trace retrieved at the forward computation.
          The stack trace is available only in the debug mode.
  
  .. versionadded:: 3.0.0
class_docstr_tok: ["Function","node","of","the","computational","graph",".","FunctionNode","is","a","class","representing","a","node","in","a","computational","graph",".","The","node","corresponds","to","an","application","of","a","differentiable","function","to","input","variables",".","When","a","differentiable","function","is","applied","to",":","class",":","`","~chainer.Variable","`","objects",",","it","creates","an","instance","of","FunctionNode","implementation","and","calls","its",":","meth",":","`","apply","`","method",".","The",":","meth",":","`","apply","`","method","basically","does","the","following","three","things",".","1",".","Adding","an","edge","from","the","function","node","to","the","variable","node","corresponding","to","each","input",".","The","node","of","each","input","is","extracted","by",":","attr",":","`","Variable.node","<","chainer.Variable.node",">","`",".","2",".","Computing","the","output","arrays","of","the","function",".","3",".","Creating","a",":","class",":","`","~chainer.Variable","`","object","for","each","output","array","and","adding","an","edge","from","the","node","of","the","variable","to","the","function","node",".","The","output","variables","are","then","returned",".","..","admonition",":",":","Example","Let","``","x","``","be","an","instance","of",":","class",":","`","~chainer.Variable","`","and","``","f","``","be","an","instance","of",":","class",":","`","FunctionNode","`","taking","only","one","argument",".","Then","the","following","code",">",">",">","import","numpy",",","chainer",">",">",">","x","=","chainer.Variable","(","numpy.zeros","(","10",")",")",">",">",">","f","=","chainer.functions.math.identity.Identity","(",")",">",">",">","y","=","f.apply","(","(","x",",",")",")","[","0","]","computes","a","new","variable","``","y","``","and","creates","backward","references",".","The","backward","references","are","actually","set","as","per","the","following","diagram",":",":","x.node","<","--","-","f","<","--","-","y.node","If","an","application","of","another","function","``","g","``","occurs","as",">",">",">","g","=","chainer.functions.math.identity.Identity","(",")",">",">",">","z","=","g.apply","(","(","x",",",")",")","[","0","]","then","the","graph","grows","with","a","branch",":",":","|","--","-","f","<","--","-","y.node","x.node","<","-+","|","--","-","g","<","--","-","z.node","Note","that","the","branching","is","correctly","managed","on","backward","computation",",","i.e",".","the","gradients","from","``","f","``","and","``","g","``","are","accumulated","to","the","gradient","of","``","x","``",".","Every","function-node","implementation","should","provide",":","meth",":","`","forward","`","and",":","meth",":","`","backward","`",".","Instead","of","overriding",":","meth",":","`","forward","`",",","one","can","also","implement",":","meth",":","`","forward_cpu","`","and",":","meth",":","`","forward_gpu","`","when","the","implementations","for","CPU","and","GPU","arrays","are","totally","different",".","Note","that","the","input","and","output","variables","are","inaccessible","from",":","meth",":","`","backward","`","by","default",".","If","it","needs","accesses","to","these","variables",",","the",":","meth",":","`","forward","`","method","(","or","its","CPU\/GPU","variants",")","has","to","call",":","meth",":","`","retain_inputs","`","and",":","meth",":","`","retain_outputs","`","appropriately",".","The","retained","input\/output","variables","can","be","accessed","from",":","meth",":","`","backward","`","by","calling",":","meth",":","`","get_retained_inputs","`","and",":","meth",":","`","get_retained_outputs","`",".","..","note",":",":","There","are","two","types","of","differentiable","functions","in","Chainer","(","since","v3",")",".","The","first","type","is","of","a","function","using","a","subclass","of",":","class",":","`","~chainer.Function","`",",","which","is","called","*","old-style","differentiable","function","*",".","The","second","type","is","of","a","function","using","a","subclass","of",":","class",":","`","FunctionNode","`",",","which","is","called","*","*","new-style","differentiable","function","*","*",".","There","are","several","advantages","on","using","the","new-style","differentiable","function",".","-","The","new-style","differentiable","function","supports","*","differentiable","backpropagation","*",".","The","backpropagated","gradients","computed","through","the","new-style","differentiable","functions","themselves","support","further","backpropagations","so","that","the","automatic","higher-order","differentiation","is","available",".","-","The","backpropagation","of","the","new-style","differentiable","function","can","be","more","computationally","efficient","because","the","interface","allows","an","implementation","to","omit","the","computation","of","unneeded","input","gradients",".","Note","that","the","new-style","differentiable","function","is","the","standard","way","of","defining","a","function","node","of","the","computational","graph","in","Chainer",";","old-","style","differentiable","functions","are","implemented","as","wrappers","of","the","new-","style","differentiable","functions",".","Attributes",":","~FunctionNode.inputs",":","A","tuple","of","the","input",":","class",":","`","~chainer.variable.VariableNode","`","objects",".","~FunctionNode.outputs",":","A","tuple","of","weak","references","to","the","output",":","class",":","`","~chainer.variable.VariableNode","`","objects",".","~FunctionNode.rank","(","int",")",":","An","ordinal","following","the","topological","order","of","the","computational","graph",".","~FunctionNode.stack",":","Stack","trace","retrieved","at","the","forward","computation",".","The","stack","trace","is","available","only","in","the","debug","mode",".","..","versionadded",":",":","3.0.0"]
docstr: Computes gradients w.r.t.\  specified inputs and accumulates them.
  
  This method provides a way to fuse the backward computation and the
  gradient accumulations in the case that the multiple functions are
  applied to the same variable.
  
  Users have to override either of this method or :meth:`backward`.
  It is often simpler to implement :meth:`backward` and is recommended
  if you do not need to provide efficient gradient accumulation.
  
  Args:
      target_input_indexes (tuple of int): Sorted indices of the input
          variables w.r.t. which the gradients are required. It is
          guaranteed that this tuple contains at least one element.
      grad_outputs (tuple of Variable): Gradients w.r.t. the output
          variables. If the gradient w.r.t. an output variable is not
          given, the corresponding element is ``None``.
      grad_inputs (tuple of Variable): Gradients w.r.t. the input
          variables specified by ``target_input_indexes``. These values
          are computed by other computation paths. If there is no
          gradient value existing for the variable, the corresponding
          element is ``None``. See also the note below.
  
  Returns:
      Tuple of variables that represent the gradients w.r.t. specified
      input variables. Unlike :meth:`backward`, the length of the tuple
      **must** be same as that of ``target_input_indices``.
  
  .. note::
  
     Gradient variables in ``grad_outputs`` are distinct, even if a
     variable is passed to multiple input arguments of the function.
     This is an implementation-detail convention to avoid the
     complication of correctly accumulating gradients in such a case.
  
     Usually, only the first position of ``grad_inputs`` corresponding to
     these input arguments may contain the gradient variable
     corresponding to that input variable, and other entries are set to
     ``None``. This is not the case with the ``lazy_grad_sum`` feature.
     This behavior might be changed in a future version.
docstr_tok: ["Computes","gradients","w.r.t.\\","specified","inputs","and","accumulates","them",".","This","method","provides","a","way","to","fuse","the","backward","computation","and","the","gradient","accumulations","in","the","case","that","the","multiple","functions","are","applied","to","the","same","variable",".","Users","have","to","override","either","of","this","method","or",":","meth",":","`","backward","`",".","It","is","often","simpler","to","implement",":","meth",":","`","backward","`","and","is","recommended","if","you","do","not","need","to","provide","efficient","gradient","accumulation",".","Args",":","target_input_indexes","(","tuple","of","int",")",":","Sorted","indices","of","the","input","variables","w.r.t",".","which","the","gradients","are","required",".","It","is","guaranteed","that","this","tuple","contains","at","least","one","element",".","grad_outputs","(","tuple","of","Variable",")",":","Gradients","w.r.t",".","the","output","variables",".","If","the","gradient","w.r.t",".","an","output","variable","is","not","given",",","the","corresponding","element","is","``","None","``",".","grad_inputs","(","tuple","of","Variable",")",":","Gradients","w.r.t",".","the","input","variables","specified","by","``","target_input_indexes","``",".","These","values","are","computed","by","other","computation","paths",".","If","there","is","no","gradient","value","existing","for","the","variable",",","the","corresponding","element","is","``","None","``",".","See","also","the","note","below",".","Returns",":","Tuple","of","variables","that","represent","the","gradients","w.r.t",".","specified","input","variables",".","Unlike",":","meth",":","`","backward","`",",","the","length","of","the","tuple","*","*","must","*","*","be","same","as","that","of","``","target_input_indices","``",".","..","note",":",":","Gradient","variables","in","``","grad_outputs","``","are","distinct",",","even","if","a","variable","is","passed","to","multiple","input","arguments","of","the","function",".","This","is","an","implementation-detail","convention","to","avoid","the","complication","of","correctly","accumulating","gradients","in","such","a","case",".","Usually",",","only","the","first","position","of","``","grad_inputs","``","corresponding","to","these","input","arguments","may","contain","the","gradient","variable","corresponding","to","that","input","variable",",","and","other","entries","are","set","to","``","None","``",".","This","is","not","the","case","with","the","``","lazy_grad_sum","``","feature",".","This","behavior","might","be","changed","in","a","future","version","."]
code: def backward_accumulate(
      self, target_input_indexes, grad_outputs, grad_inputs
  ):
      """Computes gradients w.r.t.\\  specified inputs and accumulates them.
  
      This method provides a way to fuse the backward computation and the
      gradient accumulations in the case that the multiple functions are
      applied to the same variable.
  
      Users have to override either of this method or :meth:`backward`.
      It is often simpler to implement :meth:`backward` and is recommended
      if you do not need to provide efficient gradient accumulation.
  
      Args:
          target_input_indexes (tuple of int): Sorted indices of the input
              variables w.r.t. which the gradients are required. It is
              guaranteed that this tuple contains at least one element.
          grad_outputs (tuple of Variable): Gradients w.r.t. the output
              variables. If the gradient w.r.t. an output variable is not
              given, the corresponding element is ``None``.
          grad_inputs (tuple of Variable): Gradients w.r.t. the input
              variables specified by ``target_input_indexes``. These values
              are computed by other computation paths. If there is no
              gradient value existing for the variable, the corresponding
              element is ``None``. See also the note below.
  
      Returns:
          Tuple of variables that represent the gradients w.r.t. specified
          input variables. Unlike :meth:`backward`, the length of the tuple
          **must** be same as that of ``target_input_indices``.
  
      .. note::
  
         Gradient variables in ``grad_outputs`` are distinct, even if a
         variable is passed to multiple input arguments of the function.
         This is an implementation-detail convention to avoid the
         complication of correctly accumulating gradients in such a case.
  
         Usually, only the first position of ``grad_inputs`` corresponding to
         these input arguments may contain the gradient variable
         corresponding to that input variable, and other entries are set to
         ``None``. This is not the case with the ``lazy_grad_sum`` feature.
         This behavior might be changed in a future version.
  
      """
      # If backward_accumulate is implemented, it should be equivalent to
      # the following code using backward(). This code is provided for the
      # convenience, and it's *not* used unless you override it. You don't
      # have to use backward().
      assert isinstance(target_input_indexes, tuple)
      assert isinstance(grad_outputs, tuple)
      assert isinstance(grad_inputs, tuple)
  
      gxs = self._backward_target_inputs(
          target_input_indexes, grad_outputs
      )
  
      return tuple(
          [
              gx
              if g_input is None
              else g_input
              if gx is None
              else gx + g_input
              for gx, g_input in six.moves.zip(gxs, grad_inputs)
          ]
      )
  
imports: import collections
  import contextlib
  import heapq
  import inspect
  import traceback
  import weakref
  import six
  import chainer
  from chainer import _backprop_utils
  from chainer import backend
  from chainer.backends import cuda
  from chainer import configuration
  from chainer import function_hook
  from chainer.graph_optimizations.static_graph_utilities import static_forward_optimizations
  from chainer import utils
  from chainer.utils import type_check
  from chainer import variable
  import chainerx
label_desc: Use image node_id 23 for calling the FunctionNode obj's underlying member method code with example usage: obj.backward_accumulate(target_input_indexes, grad_outputs, grad_inputs) and returns: tuple