code: def create_synchronized_iterator(actual_iterator, communicator):
      """Create a synchronized iterator from a Chainer iterator.
  
      This iterator shares the same batches on multiple processes,
      using the same random number generators to maintain the order of batch
      shuffling same.
  
      Here is an example situation.
      When we train a sequence-to-sequence model, where the encoder and
      the decoder is located on two different processes, we want to share
      the same batches on each process, thus inputs for the encoder and
      output teacher signals for the decoder become consistent.
  
      In order to use the synchronized iterator, first create the iterator
      from Chainer iterator and ChainerMN communicator::
  
          iterator = chainermn.iterators.create_synchronized_iterator(
              chainer.iterators.SerialIterator(
                  dataset, batch_size, shuffle=True),
              communicator)
  
      Then you can use it as the ordinary Chainer iterator::
  
          updater = chainer.training.StandardUpdater(iterator, optimizer)
          trainer = training.Trainer(updater)
          trainer.run()
  
      The resulting iterator shares the same shuffling order among processes
      in the specified communicator.
  
      Args:
          actual_iterator: Chainer iterator
              (e.g., ``chainer.iterators.SerialIterator``).
          communicator: ChainerMN communicator.
  
      Returns:
          The synchronized iterator based on ``actual_iterator``.
      """
      chainer.utils.experimental(
          "chainermn.iterators.create_synchronized_iterator"
      )
  
      return _SynchronizedIterator(actual_iterator, communicator)
  
file_path: chainer/chainermn/iterators/synchronized_iterator.py
imports: import chainer
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: create_synchronized_iterator(actual_iterator, communicator) and returns: _SynchronizedIterator