class_docstr: Utility to convert numpy basic slices into TF scatter_nd indices.
code: def __getitem__(self, slices):
      if not isinstance(slices, tuple):
          slices = [slices]
      else:
          slices = list(slices)
      if Ellipsis in slices:
          idx = slices.index(Ellipsis)
          slices[idx : idx + 1] = [slice(None)] * (
              self.rank - len(slices) + 1
          )
      # Remove trailing full slices for performance.
      while (
          slices
          and isinstance(slices[-1], slice)
          and slices[-1] == slice(None)
      ):
          slices.pop()
      grid = tf.meshgrid(
          *(rng[sl] for rng, sl in zip(self.ranges, slices)),
          indexing="ij",
      )
      stack = tf.stack(grid, axis=-1)
      to_squeeze = [
          i for i, sl in enumerate(slices) if not isinstance(sl, slice)
      ]
      if to_squeeze:
          stack = tf.squeeze(stack, axis=to_squeeze)
      return stack
  
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.internal import tensorshape_util
label_desc: Use image node_id 2 for calling the _Slice2Idx obj's underlying member method code with example usage: obj.__getitem__(slices) and returns: stack