code: def _VariableRankTest(
      self, np_scatter, tf_scatter, vtype, itype, repeat_indices=False
  ):
      np.random.seed(8)
      ref_shapes = [
          (3, 6),
          (3, 6),
          (3, 6, 9),
          (3, 6, 9),
          (3, 6, 9),
          (3, 6, 9),
      ]
      indices_shapes = [(2,), (2, 2), (2,), (2, 2), (2, 3), (2, 3, 3)]
      with test_util.device(use_gpu=True):
          for ref_shape, indices_shape in zip(
              ref_shapes, indices_shapes
          ):
              num_updates = indices_shape[0]
              ixdim = indices_shape[-1]
  
              indexable_area_shape = ()
              for i in range(ixdim):
                  indexable_area_shape += (ref_shape[i],)
              all_indices = [
                  list(coord)
                  for coord, _ in np.ndenumerate(
                      np.empty(indexable_area_shape, vtype)
                  )
              ]
              np.random.shuffle(all_indices)
              indices = np.array(all_indices[:num_updates])
  
              if num_updates > 1 and repeat_indices:
                  indices = indices[: num_updates // 2]
                  for _ in range(num_updates - num_updates // 2):
                      indices = np.append(
                          indices,
                          [
                              indices[
                                  np.random.randint(num_updates // 2)
                              ]
                          ],
                          axis=0,
                      )
                  np.random.shuffle(indices)
              indices = _AsType(indices[:num_updates], itype)
  
              updates_shape = (num_updates,)
              for i in range(ixdim, len(ref_shape)):
                  updates_shape += (ref_shape[i],)
              updates = _AsType(
                  np.random.randn(*(updates_shape)), vtype
              )
              ref = _AsType(np.random.randn(*(ref_shape)), vtype)
  
              # Scatter via numpy
              new = ref.copy()
              np_scatter(new, indices, updates)
              # Scatter via tensorflow
              ref_var = variable_v1.VariableV1(ref)
              self.evaluate(ref_var.initializer)
              self.evaluate(tf_scatter(ref_var, indices, updates))
  
              # Compare
              self.assertAllClose(new, self.evaluate(ref_var))
  
file_path: tensorflow-upstream/tensorflow/python/kernel_tests/v1_compat_tests/scatter_nd_ops_test.py
imports: import functools
  import numpy
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import state_ops
  from tensorflow.python.ops import variable_v1
  from tensorflow.python.platform import test
label_desc: Use image node_id 1 for calling the StatefulScatterNdTest obj's underlying member method code with example usage: obj._VariableRankTest(np_scatter, tf_scatter, vtype, itype, repeat_indices) without return types