code: def _checkGrad(self, x, block_size, data_format):
      # NCHW is implemented for only GPU.
      if data_format == "NCHW" and not test.is_gpu_available():
          return
  
      assert 4 == x.ndim
  
      def func(x):
          return array_ops.space_to_depth(
              x, block_size, data_format=data_format
          )
  
      with test_util.use_gpu():
          with self.cached_session():
              (
                  theoretical,
                  numerical,
              ) = gradient_checker_v2.compute_gradient(
                  func, [ops.convert_to_tensor(x)]
              )
              self.assertAllClose(
                  theoretical, numerical, rtol=1e-2, atol=1e-2
              )
  
imports: import numpy
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gen_array_ops
  from tensorflow.python.ops import gradient_checker_v2
  from tensorflow.python.ops import math_ops
  from tensorflow.python.platform import test
  from tensorflow.python.platform import tf_logging
label_desc: Use image node_id 1 for calling the SpaceToDepthGradientTest obj's underlying member method code with example usage: obj._checkGrad(x, block_size, data_format) and returns: array_ops