class_docstr: __init__(self, iterator, target, converter=convert.concat_examples, device=None, eval_hook=None, eval_func=None, *, progress_bar=False)
  
  Trainer extension to evaluate models on a validation set.
  
  This extension evaluates the current models by a given evaluation function.
  It creates a :class:`~chainer.Reporter` object to store values observed in
  the evaluation function on each iteration. The report for all iterations
  are aggregated to :class:`~chainer.DictSummary`. The collected mean values
  are further reported to the reporter object of the trainer, where the name
  of each observation is prefixed by the evaluator name. See
  :class:`~chainer.Reporter` for details in naming rules of the reports.
  
  Evaluator has a structure to customize similar to that of
  :class:`~chainer.training.updaters.StandardUpdater`.
  The main differences are:
  
  - There are no optimizers in an evaluator. Instead, it holds links
    to evaluate.
  - An evaluation loop function is used instead of an update function.
  - Preparation routine can be customized, which is called before each
    evaluation. It can be used, e.g., to initialize the state of stateful
    recurrent networks.
  
  There are two ways to modify the evaluation behavior besides setting a
  custom evaluation function. One is by setting a custom evaluation loop via
  the ``eval_func`` argument. The other is by inheriting this class and
  overriding the :meth:`evaluate` method. In latter case, users have to
  create and handle a reporter object manually. Users also have to copy the
  iterators before using them, in order to reuse them at the next time of
  evaluation. In both cases, the functions are called in testing mode
  (i.e., ``chainer.config.train`` is set to ``False``).
  
  This extension is called at the end of each epoch by default.
  
  Args:
      iterator: Dataset iterator for the validation dataset. It can also be
          a dictionary of iterators. If this is just an iterator, the
          iterator is registered by the name ``'main'``.
      target: Link object or a dictionary of links to evaluate. If this is
          just a link object, the link is registered by the name ``'main'``.
      converter: Converter function to build input arrays.
          :func:`~chainer.dataset.concat_examples` is used by default.
      device: Device to which the validation data is sent. Negative value
          indicates the host memory (CPU).
      eval_hook: Function to prepare for each evaluation process. It is
          called at the beginning of the evaluation. The evaluator extension
          object is passed at each call.
      eval_func: Evaluation function called at each iteration. The target
          link to evaluate as a callable is used by default.
      progress_bar: Boolean flag to show a progress bar while training,
          which is similar to
          :class:`~chainer.training.extensions.ProgressBar`.
          (default: ``False``)
  
  .. warning::
  
      The argument ``progress_bar`` is experimental.
      The interface can change in the future.
  
  Attributes:
      converter: Converter function.
      device: Device to which the validation data is sent.
      eval_hook: Function to prepare for each evaluation process.
      eval_func: Evaluation function called at each iteration.
class_docstr_tok: ["__init__","(","self",",","iterator",",","target",",","converter=convert.concat_examples",",","device=None",",","eval_hook=None",",","eval_func=None",",","*",",","progress_bar=False",")","Trainer","extension","to","evaluate","models","on","a","validation","set",".","This","extension","evaluates","the","current","models","by","a","given","evaluation","function",".","It","creates","a",":","class",":","`","~chainer.Reporter","`","object","to","store","values","observed","in","the","evaluation","function","on","each","iteration",".","The","report","for","all","iterations","are","aggregated","to",":","class",":","`","~chainer.DictSummary","`",".","The","collected","mean","values","are","further","reported","to","the","reporter","object","of","the","trainer",",","where","the","name","of","each","observation","is","prefixed","by","the","evaluator","name",".","See",":","class",":","`","~chainer.Reporter","`","for","details","in","naming","rules","of","the","reports",".","Evaluator","has","a","structure","to","customize","similar","to","that","of",":","class",":","`","~chainer.training.updaters.StandardUpdater","`",".","The","main","differences","are",":","-","There","are","no","optimizers","in","an","evaluator",".","Instead",",","it","holds","links","to","evaluate",".","-","An","evaluation","loop","function","is","used","instead","of","an","update","function",".","-","Preparation","routine","can","be","customized",",","which","is","called","before","each","evaluation",".","It","can","be","used",",","e.g.",",","to","initialize","the","state","of","stateful","recurrent","networks",".","There","are","two","ways","to","modify","the","evaluation","behavior","besides","setting","a","custom","evaluation","function",".","One","is","by","setting","a","custom","evaluation","loop","via","the","``","eval_func","``","argument",".","The","other","is","by","inheriting","this","class","and","overriding","the",":","meth",":","`","evaluate","`","method",".","In","latter","case",",","users","have","to","create","and","handle","a","reporter","object","manually",".","Users","also","have","to","copy","the","iterators","before","using","them",",","in","order","to","reuse","them","at","the","next","time","of","evaluation",".","In","both","cases",",","the","functions","are","called","in","testing","mode","(","i.e.",",","``","chainer.config.train","``","is","set","to","``","False","``",")",".","This","extension","is","called","at","the","end","of","each","epoch","by","default",".","Args",":","iterator",":","Dataset","iterator","for","the","validation","dataset",".","It","can","also","be","a","dictionary","of","iterators",".","If","this","is","just","an","iterator",",","the","iterator","is","registered","by","the","name","``","'main","'","``",".","target",":","Link","object","or","a","dictionary","of","links","to","evaluate",".","If","this","is","just","a","link","object",",","the","link","is","registered","by","the","name","``","'main","'","``",".","converter",":","Converter","function","to","build","input","arrays",".",":","func",":","`","~chainer.dataset.concat_examples","`","is","used","by","default",".","device",":","Device","to","which","the","validation","data","is","sent",".","Negative","value","indicates","the","host","memory","(","CPU",")",".","eval_hook",":","Function","to","prepare","for","each","evaluation","process",".","It","is","called","at","the","beginning","of","the","evaluation",".","The","evaluator","extension","object","is","passed","at","each","call",".","eval_func",":","Evaluation","function","called","at","each","iteration",".","The","target","link","to","evaluate","as","a","callable","is","used","by","default",".","progress_bar",":","Boolean","flag","to","show","a","progress","bar","while","training",",","which","is","similar","to",":","class",":","`","~chainer.training.extensions.ProgressBar","`",".","(","default",":","``","False","``",")","..","warning",":",":","The","argument","``","progress_bar","``","is","experimental",".","The","interface","can","change","in","the","future",".","Attributes",":","converter",":","Converter","function",".","device",":","Device","to","which","the","validation","data","is","sent",".","eval_hook",":","Function","to","prepare","for","each","evaluation","process",".","eval_func",":","Evaluation","function","called","at","each","iteration","."]
code: def __init__(
      self,
      iterator,
      target,
      converter=convert.concat_examples,
      device=None,
      eval_hook=None,
      eval_func=None,
      **kwargs,
  ):
      (progress_bar,) = argument.parse_kwargs(
          kwargs, ("progress_bar", False)
      )
  
      if device is not None:
          device = backend.get_device(device)
  
      if isinstance(iterator, iterator_module.Iterator):
          iterator = {"main": iterator}
      self._iterators = iterator
  
      if isinstance(target, link.Link):
          target = {"main": target}
      self._targets = target
  
      self.converter = converter
      self.device = device
      self.eval_hook = eval_hook
      self.eval_func = eval_func
  
      self._progress_bar = progress_bar
  
      for key, iter in six.iteritems(iterator):
          if isinstance(
              iter,
              (
                  iterators.SerialIterator,
                  iterators.MultiprocessIterator,
                  iterators.MultithreadIterator,
              ),
          ) and getattr(iter, "repeat", False):
              msg = "The `repeat` property of the iterator {} "
              "is set to `True`. Typically, the evaluator sweeps "
              "over iterators until they stop, "
              "but as the property being `True`, this iterator "
              "might not stop and evaluation could go into "
              "an infinite loop. "
              "We recommend to check the configuration "
              "of iterators".format(key)
              warnings.warn(msg)
  
imports: import copy
  import datetime
  import warnings
  import six
  from chainer import backend
  from chainer import configuration
  from chainer.dataset import convert
  from chainer.dataset import iterator
  from chainer import function
  from chainer import iterators
  from chainer import link
  from chainer import reporter
  from chainer.training import extension
  from chainer.training.extensions import util
  from chainer.utils import argument
label_desc: Use image node_id 1 to create a new Evaluator object from inherited base classes: extension with example: obj = Evaluator(iterator, target, converter, device, eval_hook, eval_func)