class_docstr: Schedules periodic evaluation during training.
  
  This plugin is automatically configured and added by the BaseStrategy.
class_docstr_tok: ["Schedules","periodic","evaluation","during","training",".","This","plugin","is","automatically","configured","and","added","by","the","BaseStrategy","."]
docstr: Init.
  
  :param eval_every: the frequency of the calls to `eval` inside the
      training loop. -1 disables the evaluation. 0 means `eval` is called
      only at the end of the learning experience. Values >0 mean that
      `eval` is called every `eval_every` epochs and at the end of the
      learning experience.
  :param peval_mode: one of {'epoch', 'iteration'}. Decides whether the
      periodic evaluation during training should execute every
      `eval_every` epochs or iterations (Default='epoch').
  :param do_initial: whether to evaluate before each `train` call.
      Occasionally needed becuase some metrics need to know the
      accuracy before training.
docstr_tok: ["Init",".",":","param","eval_every",":","the","frequency","of","the","calls","to","`","eval","`","inside","the","training","loop",".","-1","disables","the","evaluation",".","0","means","`","eval","`","is","called","only","at","the","end","of","the","learning","experience",".","Values",">","0","mean","that","`","eval","`","is","called","every","`","eval_every","`","epochs","and","at","the","end","of","the","learning","experience",".",":","param","peval_mode",":","one","of","{","'epoch","'",",","'iteration","'","}",".","Decides","whether","the","periodic","evaluation","during","training","should","execute","every","`","eval_every","`","epochs","or","iterations","(","Default='epoch","'",")",".",":","param","do_initial",":","whether","to","evaluate","before","each","`","train","`","call",".","Occasionally","needed","becuase","some","metrics","need","to","know","the","accuracy","before","training","."]
code: def __init__(
      self, eval_every=-1, peval_mode="epoch", do_initial=True
  ):
      """Init.
  
      :param eval_every: the frequency of the calls to `eval` inside the
          training loop. -1 disables the evaluation. 0 means `eval` is called
          only at the end of the learning experience. Values >0 mean that
          `eval` is called every `eval_every` epochs and at the end of the
          learning experience.
      :param peval_mode: one of {'epoch', 'iteration'}. Decides whether the
          periodic evaluation during training should execute every
          `eval_every` epochs or iterations (Default='epoch').
      :param do_initial: whether to evaluate before each `train` call.
          Occasionally needed becuase some metrics need to know the
          accuracy before training.
      """
      super().__init__()
      assert peval_mode in {"epoch", "iteration"}
      self.eval_every = eval_every
      self.peval_mode = peval_mode
      self.do_initial = do_initial and eval_every > -1
      self.do_final = None
      self._is_eval_updated = False
  
imports: import copy
  import logging
  import unittest
  import numpy
  import torch
  from torch.utils.data import DataLoader
  from typing import Optional, Sequence, Union
  from torch.nn import Module, CrossEntropyLoss
  from torch.optim import SGD
  from avalanche.benchmarks.scenarios import ClassificationExperience
  from avalanche.benchmarks.utils.data_loader import TaskBalancedDataLoader
  from avalanche.models import DynamicModule, SimpleMLP, MTSimpleMLP
  from avalanche.models.dynamic_optimizers import reset_optimizer
  from avalanche.models.utils import avalanche_forward
  from avalanche.training import Cumulative
  from avalanche.training.plugins.clock import Clock
  from avalanche.training.plugins import EvaluationPlugin
  from avalanche.training.templates import SupervisedTemplate
  from avalanche.training.utils import trigger_plugins
  from tests.unit_tests_utils import get_fast_benchmark
label_desc: Use image node_id 1 to create a new PeriodicEval object  with example: obj = PeriodicEval(eval_every, peval_mode, do_initial)