code: def scatter_dataset(
      dataset,
      comm,
      root=0,
      shuffle=False,
      seed=None,
      max_buf_len=256 * 1024 * 1024,
      *,
      force_equal_length=True,
  ):
      """Scatter the given dataset to the workers in the communicator.
  
      The dataset of worker ``root``
      (i.e., the worker whose ``comm.rank`` is ``root``) is
      scattered to all workers. The given dataset of other workers are ignored.
      The dataset is split to sub datasets of almost equal sizes and scattered
      to workers. To create a sub dataset, ``chainer.datasets.SubDataset`` is
      used.
  
      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:
          dataset: A dataset (e.g., ``list``, ``numpy.ndarray``,
              ``chainer.datasets.TupleDataset``, ...).
          comm: ChainerMN communicator or MPI4py communicator.
          shuffle (bool): If ``True``, the order of examples is shuffled
              before being scattered.
          root (int): The root process of the scatter operation.
          seed (int): Seed the generator used for the permutation of indexes.
              If an integer being convertible to 32 bit unsigned integers is
              specified, it is guaranteed that each sample
              in the given dataset always belongs to a specific subset.
              If ``None``, the permutation is changed randomly.
          max_buf_len (int): Max buffer size to be used at broadcasting
              binaries. Must not be larger than 2147483647.
          force_equal_length (bool):
              Force the scattered fragments of the dataset have equal
              length. If ``True``, number of scattered examples is
              guaranteed to be equal among processes and scattered
              datasets may have duplication among processes. Otherwise,
              number of scattered examples may not be equal among
              processes, but scattered examples are guaranteed to have
              no duplication among processes, intended for strict
              evaluation of test dataset to avoid duplicated examples.
  
      Returns:
          Scattered dataset.
  
      """
  
      assert 0 <= root and root < comm.size
  
      order = None
      if shuffle and dataset is not None:
          n_total_samples = len(dataset)
          order = numpy.random.RandomState(seed).permutation(
              n_total_samples
          )
  
      data = (dataset, order) if comm.rank == root else None
      data = comm.bcast_obj(data, max_buf_len=max_buf_len, root=root)
  
      assert data is not None
      (dataset, order) = data
  
      (b, e) = scatter_index(
          len(dataset),
          comm,
          root,
          force_equal_length=force_equal_length,
      )
      return chainer.datasets.SubDataset(dataset, b, e, order)
  
file_path: chainer/chainermn/datasets/scatter.py
imports: import warnings
  import chainer.datasets
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: scatter_dataset(dataset, comm, root, shuffle, seed, max_buf_len) and returns: chainer