code: def scatter_index(
      n_total_samples, comm, root=0, *, force_equal_length=True
  ):
      """Scatters only index to avoid heavy dataset broadcast
  
      This is core functionality of ``scatter_dataset``, which is
      almost equal to following code snippet::
  
          (b, e) = scatter_index(len(dataset), comm)
          order = None
          if shuffle:
              order = numpy.random.RandomState(seed).permutation(
                  n_total_samples)
              order = comm.bcast_obj(order)
          dataset = SubDataset(dataset, b, e, order)
  
      Note::
          Make sure ``force_equal_length`` flag is *not* off for
          multinode evaluator or multinode updaters, which assume that
          the iterator has the same lengths among processes to work
          correctly.
  
      Args:
          n_total_samples (int): number of total samples to scatter
          comm: ChainerMN communicator object
          root (int): root rank to coordinate the operation
          force_equal_length (bool):
              Force the scattered fragments of the index have equal
              length. If ``True``, number of scattered indices is
              guaranteed to be equal among processes and scattered
              datasets may have duplication among processes. Otherwise,
              number of scattered indices may not be equal among
              processes, but scattered indices are guaranteed to have
              no duplication among processes, intended for strict
              evaluation of test dataset to avoid duplicated examples.
  
      Returns:
          Tuple of two integers, that stands for beginning and ending
          offsets of the assigned sub part of samples. The ending offset
          is not border inclusive.
  
      """
      if comm.rank == root:
          for i, b, e in _scatter_index(
              n_total_samples, comm.size, force_equal_length
          ):
              if i == root:
                  mine = (b, e)
              else:
                  comm.send_obj((b, e), dest=i)
          return mine
      else:
          return comm.recv_obj(source=root)
  
file_path: chainer/chainermn/datasets/scatter.py
imports: import warnings
  import chainer.datasets
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: scatter_index(n_total_samples, comm, root) and returns: mine, comm