code: def _NumpyScatterNd(ref, indices, updates, op):
      ixdim = indices.shape[-1]
      num_updates = indices.size // ixdim
      total_nd = len(ref.shape)
      slice_size = 1
      for i in range(ixdim, total_nd):
          slice_size *= ref.shape[i]
      flat_indices = _FlatInnerDims(indices)
      flat_updates = updates.reshape((num_updates, slice_size))
      output_flat = _FlatOuterDims(ref, ixdim + 1)
      for ix_updates, ix_output in enumerate(flat_indices):
          ix_output = tuple(ix_output)
          output_flat[ix_output] = op(
              output_flat[ix_output], flat_updates[ix_updates]
          )
      return output_flat.reshape(ref.shape)
  
imports: import functools
  import numpy
  from tensorflow.compiler.tests import xla_test
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 4 for calling a global function with example usage: _NumpyScatterNd(ref, indices, updates, op) and returns: output_flat