class_docstr: Dataset iterator that loads examples in parallel.
  
  This is an implementation of :class:`~chainer.dataset.Iterator` that loads
  examples with worker processes. It uses the standard :mod:`multiprocessing`
  module to parallelize the loading. The dataset is sent to the worker
  processes in the standard way using pickle.
  
  Note that this iterator effectively prefetches the examples for the next
  batch asynchronously after the current batch is returned.
  
  This iterator saves ``-1`` instead of ``None`` in snapshots since some
  serializers do not support ``None``.
  
  .. note::
  
          When you are using OpenCV somewhere in your code and the
          ``MultiprocessIterator`` is used in the training code, the
          training loop may get stuck at some point. In such situation,
          there are several workarounds to prevent the process got stuck.
  
          1. Set the environment variable as follows: ``OMP_NUM_THREADS=1``
          2. Add ``cv2.setNumThreads(0)`` right after ``import cv2`` in your
             training script.
          3. Use :class:`~chainer.iterators.MultithreadIterator` instead of
             ``MultiprocessIterator``.
  
  Args:
      dataset (~chainer.dataset.Dataset): Dataset to iterate.
      batch_size (int): Number of examples within each batch.
      repeat (bool): If ``True``, it infinitely loops over the dataset.
          Otherwise, it stops iteration at the end of the first epoch.
      shuffle (bool): If ``True``, the order of examples is shuffled at the
          beginning of each epoch. Otherwise, examples are extracted in the
          order of indexes. If ``None`` and no ``order_sampler`` is given,
          the behavior is the same as the case with ``shuffle=True``.
      n_processes (int): Number of worker processes. The number of CPUs is
          used by default.
      n_prefetch (int): Number of prefetch batches.
      shared_mem (int): The size of using shared memory per data.
          If ``None``, size is adjusted automatically.
      dataset_timeout (float): :class:`MultiprocessIterator.TimeoutWarning`
          will be issued after this time in seconds elapsed in each dataset
          realization. ``None`` to disable the warning. You can turn this
          warning into an error by using :func:`warnings.simplefilter`::
  
              warnings.simplefilter(
                  'error',
                  chainer.iterators.MultiprocessIterator.TimeoutWarning)
  
      order_sampler (callable): A callable that generates the order
          of the indices to sample in the next epoch when a epoch finishes.
          This function should take two arguments: the current order
          and the current position of the iterator.
          This should return the next order. The size of the order
          should remain constant.
          This option cannot be used when ``shuffle`` is not ``None``.
      maxtasksperchild (int): Number of tasks a worker of prefetch process
          can complete before it will exit and be replaced with a fresh
          worker process, to enable unused resources to be freed. If
          ``None``, worker processes will live as long as the pool.
class_docstr_tok: ["Dataset","iterator","that","loads","examples","in","parallel",".","This","is","an","implementation","of",":","class",":","`","~chainer.dataset.Iterator","`","that","loads","examples","with","worker","processes",".","It","uses","the","standard",":","mod",":","`","multiprocessing","`","module","to","parallelize","the","loading",".","The","dataset","is","sent","to","the","worker","processes","in","the","standard","way","using","pickle",".","Note","that","this","iterator","effectively","prefetches","the","examples","for","the","next","batch","asynchronously","after","the","current","batch","is","returned",".","This","iterator","saves","``","-1","``","instead","of","``","None","``","in","snapshots","since","some","serializers","do","not","support","``","None","``",".","..","note",":",":","When","you","are","using","OpenCV","somewhere","in","your","code","and","the","``","MultiprocessIterator","``","is","used","in","the","training","code",",","the","training","loop","may","get","stuck","at","some","point",".","In","such","situation",",","there","are","several","workarounds","to","prevent","the","process","got","stuck",".","1",".","Set","the","environment","variable","as","follows",":","``","OMP_NUM_THREADS=1","``","2",".","Add","``","cv2.setNumThreads","(","0",")","``","right","after","``","import","cv2","``","in","your","training","script",".","3",".","Use",":","class",":","`","~chainer.iterators.MultithreadIterator","`","instead","of","``","MultiprocessIterator","``",".","Args",":","dataset","(","~chainer.dataset.Dataset",")",":","Dataset","to","iterate",".","batch_size","(","int",")",":","Number","of","examples","within","each","batch",".","repeat","(","bool",")",":","If","``","True","``",",","it","infinitely","loops","over","the","dataset",".","Otherwise",",","it","stops","iteration","at","the","end","of","the","first","epoch",".","shuffle","(","bool",")",":","If","``","True","``",",","the","order","of","examples","is","shuffled","at","the","beginning","of","each","epoch",".","Otherwise",",","examples","are","extracted","in","the","order","of","indexes",".","If","``","None","``","and","no","``","order_sampler","``","is","given",",","the","behavior","is","the","same","as","the","case","with","``","shuffle=True","``",".","n_processes","(","int",")",":","Number","of","worker","processes",".","The","number","of","CPUs","is","used","by","default",".","n_prefetch","(","int",")",":","Number","of","prefetch","batches",".","shared_mem","(","int",")",":","The","size","of","using","shared","memory","per","data",".","If","``","None","``",",","size","is","adjusted","automatically",".","dataset_timeout","(","float",")",":",":","class",":","`","MultiprocessIterator.TimeoutWarning","`","will","be","issued","after","this","time","in","seconds","elapsed","in","each","dataset","realization",".","``","None","``","to","disable","the","warning",".","You","can","turn","this","warning","into","an","error","by","using",":","func",":","`","warnings.simplefilter","`",":",":","warnings.simplefilter","(","'error","'",",","chainer.iterators.MultiprocessIterator.TimeoutWarning",")","order_sampler","(","callable",")",":","A","callable","that","generates","the","order","of","the","indices","to","sample","in","the","next","epoch","when","a","epoch","finishes",".","This","function","should","take","two","arguments",":","the","current","order","and","the","current","position","of","the","iterator",".","This","should","return","the","next","order",".","The","size","of","the","order","should","remain","constant",".","This","option","can","not","be","used","when","``","shuffle","``","is","not","``","None","``",".","maxtasksperchild","(","int",")",":","Number","of","tasks","a","worker","of","prefetch","process","can","complete","before","it","will","exit","and","be","replaced","with","a","fresh","worker","process",",","to","enable","unused","resources","to","be","freed",".","If","``","None","``",",","worker","processes","will","live","as","long","as","the","pool","."]
code: def _reset_state(self, current_position, epoch, is_new_epoch, order):
      if self._finalized:
          raise NotImplementedError(
              "Reset of finalized MultiProcessIterator is currently not "
              "supported."
          )
      self._state = _statemachine.IteratorState(
          current_position, epoch, is_new_epoch, order
      )
      self._comm.reset(self._state)
  
imports: from __future__ import division
  import datetime
  import multiprocessing
  from multiprocessing import sharedctypes
  import signal
  import sys
  import threading
  import warnings
  import numpy
  import six
  from chainer.dataset import iterator
  from chainer.iterators import _statemachine
  from chainer.iterators.order_samplers import ShuffleOrderSampler
label_desc: Use image node_id 13 for calling the MultiprocessIterator obj's underlying member method code with example usage: obj._reset_state(current_position, epoch, is_new_epoch, order) without return types