code: def __init__(
      self,
      func,
      xs,
      gys,
      params,
      eps,
      atol,
      rtol,
      no_gxs,
      dtype,
      detect_nondifferentiable,
      is_immutable_params,
  ):
      # If `is_immutable_params` is `False`, `params` are expected to be of
      # type `chainer.Parameter` and are updated in-place.
      # To run `_CheckBackward` with ChainerX ndarrays however which cannot
      # be updated in-place when wrapped in `chainer.Parameter`s, this flag
      # should be `True` and parameters should be given as ndarrays.
      # `func` in the former case must take inputs as arguments only. In the
      # latter, it must take the parameters in addition.
  
      if dtype is not None and numpy.dtype(dtype).kind != "f":
          raise ValueError("`dtype` is allowed only float type")
      if is_immutable_params:
          if not all(
              isinstance(p, chainer.get_array_types()) for p in params
          ):
              raise ValueError(
                  "All parameters in `params` must be ndarrays if "
                  "`is_immutable_params` is `True`. Actual: {}.".format(
                      ", ".join(str(type(p)) for p in params)
                  )
              )
  
      xs = _as_tuple(xs)
      if gys is not None:
          gys = _as_tuple(gys)
      params = _as_tuple(params)
  
      if no_gxs is None:
          no_gxs = [
              None if x is None else x.dtype.kind != "f" for x in xs
          ]
      else:
          if len(no_gxs) != len(xs):
              raise ValueError(
                  "Length of no_grads param and xs should be same.\n"
                  "Actual: {0} != {1}".format(len(no_gxs), len(xs))
              )
  
      device = backend.get_device_from_array(*xs)
  
      if device.xp is chainerx:
          if params and not is_immutable_params:
              raise NotImplementedError(
                  "gradient_check does not support params argument for "
                  "ChainerX arrays"
              )
  
      self.device = device
  
      self.func = func
      self.xs = xs
      self.gys = gys
      self.params = params
      self.no_gxs = no_gxs
      self.atol = atol
      self.rtol = rtol
      self.is_immutable_params = is_immutable_params
      # options for numeric gradients
      self.eps = eps
      self.dtype = dtype
      self.detect_nondifferentiable = detect_nondifferentiable
  
imports: from __future__ import absolute_import
  import warnings
  import numpy
  import six
  import chainer
  from chainer import backend
  from chainer.backends import _cpu
  from chainer.backends import cuda
  from chainer import configuration
  from chainer import testing
  from chainer import utils
  from chainer import variable
  import chainerx
label_desc: Use image node_id 1 to create a new _CheckBackward object from inherited base classes: object with example: obj = _CheckBackward(func, xs, gys, params, eps, atol, rtol, no_gxs, dtype, detect_nondifferentiable, is_immutable_params)