class_docstr: Adapter class to wrap Function with FunctionNode.
  
  While :class:`~chainer.FunctionNode` provides the interface
  of new-style differentiable functions, the old-style
  :class:`~chainer.Function` can still be used for the backward
  compatibility.
  This class provides an adapter of there interface; it adds
  :class:`~chainer.FunctionNode` interface to any
  :class:`~chainer.Function` object by delegation.
  
  .. note::
  
     The ownership of :class:`FunctionAdapter` and :class:`~chainer.Function`
     is a bit tricky.
     At the initialization, :class:`FunctionAdapter` is owned by the
     :class:`~chainer.Function` object.
     Once the function is applied to variables, the ownership is reversed;
     the adapter becomes the owner of the
     :class:`~chainer.Function` object and the :class:`~chainer.Function`
     object changes the reference to a weak one.
  
  Args:
      function (~chainer.Function): The function object to wrap.
  
  .. versionadded:: 3.0.0
class_docstr_tok: ["Adapter","class","to","wrap","Function","with","FunctionNode",".","While",":","class",":","`","~chainer.FunctionNode","`","provides","the","interface","of","new-style","differentiable","functions",",","the","old-style",":","class",":","`","~chainer.Function","`","can","still","be","used","for","the","backward","compatibility",".","This","class","provides","an","adapter","of","there","interface",";","it","adds",":","class",":","`","~chainer.FunctionNode","`","interface","to","any",":","class",":","`","~chainer.Function","`","object","by","delegation",".","..","note",":",":","The","ownership","of",":","class",":","`","FunctionAdapter","`","and",":","class",":","`","~chainer.Function","`","is","a","bit","tricky",".","At","the","initialization",",",":","class",":","`","FunctionAdapter","`","is","owned","by","the",":","class",":","`","~chainer.Function","`","object",".","Once","the","function","is","applied","to","variables",",","the","ownership","is","reversed",";","the","adapter","becomes","the","owner","of","the",":","class",":","`","~chainer.Function","`","object","and","the",":","class",":","`","~chainer.Function","`","object","changes","the","reference","to","a","weak","one",".","Args",":","function","(","~chainer.Function",")",":","The","function","object","to","wrap",".","..","versionadded",":",":","3.0.0"]
code: def backward(self, target_input_indexes, grad_outputs):
      retained_inputs = self.get_retained_inputs()
      inputs = [None] * len(self.inputs)
      in_data = [None] * len(self.inputs)
      for retained, i_in in six.moves.zip(
          retained_inputs, self._input_indexes_to_retain
      ):
          inputs[i_in] = retained
          in_data[i_in] = None if retained is None else retained.array
      in_data = tuple(in_data)
  
      grad_out_data = tuple(
          [
              None if grad is None else grad.array
              for grad in grad_outputs
          ]
      )
  
      is_chainerx_fallback_mode = self._is_chainerx_fallback_mode
      if is_chainerx_fallback_mode:
          # Convert input and output gradients to numpy/cupy
          in_data = backend.from_chx(in_data)
          grad_out_data = backend.from_chx(grad_out_data)
  
      # Call Function.backward
      with chainer.using_device(
          backend.get_device_from_array(*(in_data + grad_out_data))
      ):
          if is_chainerx_fallback_mode:
              # Enable attribute fallback
              with function_node._chainerx_attribute_fallback(
                  self._function, self.chainerx_device
              ):
                  gxs = self._function.backward(in_data, grad_out_data)
          else:
              gxs = self._function.backward(in_data, grad_out_data)
  
      # Check gradients
      for x, gx in six.moves.zip(self.inputs, gxs):
          if gx is not None:
              variable._check_grad_type(self, x, True, gx)
  
      # Convert input gradients back to ChainerX
      if is_chainerx_fallback_mode:
          gxs = backend.to_chx(gxs)
  
      ret = []
      for i in target_input_indexes:
          if gxs[i] is None:
              g = None
          else:
              # Intentionally not passing requires_grad=False so that
              # backprop routines can raise an error when a further backprop
              # is attempted against this gradient variable.
              g = variable.Variable(gxs[i])
              if g.xp is not chainerx:
                  g.node._old_style_grad_generator = (
                      self._function.label
                  )
          ret.append(g)
  
      return tuple(ret)
  
imports: from __future__ import absolute_import
  import warnings
  import weakref
  import six
  import chainer
  from chainer import backend
  from chainer.backends import cuda
  from chainer import configuration
  from chainer.function_hook import FunctionHook
  from chainer import function_node
  from chainer import variable
  import chainerx
label_desc: Use image node_id 7 for calling the FunctionAdapter obj's underlying member method code with example usage: obj.backward(target_input_indexes, grad_outputs) and returns: tuple