code: def testGradientsRank2SlicesWithEmptySpace(self):
      indices = constant_op.constant(
          [[2], [0], [5]], dtype=dtypes.int32
      )
      inputs = constant_op.constant(
          [
              [1, 2, 3, 4, 5, 6, 7, 8, 9],
              [1, 2, 3, 4, 5, 6, 7, 8, 9],
              [1, 2, 3, 4, 5, 6, 7, 8, 9],
              [1, 2, 3, 4, 5, 6, 7, 8, 9],
              [1, 2, 3, 4, 5, 6, 7, 8, 9],
              [1, 2, 3, 4, 5, 6, 7, 8, 9],
          ],
          dtype=dtypes.float64,
      )
      outputs = array_ops.gather_nd(inputs, indices)
      grad_vals = constant_op.constant(
          [
              [1, 1, 1, 1, 1, 1, 1, 1, 1],
              [2, 2, 2, 2, 2, 2, 2, 2, 2],
              [3, 3, 3, 3, 3, 3, 3, 3, 3],
          ],
          dtype=dtypes.float64,
      )
      grads = gradients_impl.gradients(
          [outputs], [inputs], [grad_vals]
      )[0]
      expected_grads = np.array(
          [
              [2, 2, 2, 2, 2, 2, 2, 2, 2],
              [0, 0, 0, 0, 0, 0, 0, 0, 0],
              [1, 1, 1, 1, 1, 1, 1, 1, 1],
              [0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0, 0, 0, 0, 0, 0, 0, 0, 0],
              [3, 3, 3, 3, 3, 3, 3, 3, 3],
          ],
          dtype=np.float64,
      )
      with self.session():
          self.assertIndexedSlices(grads)
          self.assertAllEqual(
              expected_grads, ops.convert_to_tensor(grads)
          )
  
imports: import time
  import numpy
  from tensorflow.python.client import session
  from tensorflow.python.eager import context
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.ops import ref_variable
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
label_desc: Use image node_id 23 for calling the GatherNdTest obj's underlying member method code with example usage: obj.testGradientsRank2SlicesWithEmptySpace() without return types