code: def backward(self, inputs, grads):
      gpu = backend.get_array_module(*inputs) is cuda.cupy
  
      # TODO(unno): We can remove redundant gpu-cpu copy using
      # theano.sandbox.cuda.basic_ops.gpu_from_host
      args = [cuda.to_cpu(x) for x in inputs + grads]
  
      outputs = self.backward_func(*args)
      assert len(outputs) == len(inputs)
  
      if gpu:
          # TODO(unno): We can remove redundant gpu-cpu copy using
          # theano.sandbox.cuda.CudaNdarray.gpudata
          device = cuda.get_device_from_array(inputs)
          outputs = [cuda.to_gpu(x, device) for x in outputs]
  
      results = []
      for o, i in zip(outputs, inputs):
          if i.dtype.kind != "f":
              o = None
          elif o.dtype != i.dtype:
              o = o.astype(i.dtype)
          results.append(o)
      return tuple(results)
  
file_path: chainer/chainer/functions/theano/theano_function.py
imports: import six
  from chainer import backend
  from chainer.backends import cuda
  from chainer import function
  from chainer.utils import type_check
label_desc: Use image node_id 4 for calling the TheanoFunction obj's underlying member method code with example usage: obj.backward(inputs, grads) and returns: tuple