class_docstr: ER AML, as proposed in
  "New Insights on Reducing Abrupt Representation
  Change in Online Continual Learning"
  by Lucas Caccia et. al.
  https://openreview.net/forum?id=N8MaByOzUfb
class_docstr_tok: ["ER","AML",",","as","proposed","in","''","New","Insights","on","Reducing","Abrupt","Representation","Change","in","Online","Continual","Learning","''","by","Lucas","Caccia","et",".","al",".","https",":","\/\/openreview.net\/forum","?","id=N8MaByOzUfb"]
docstr: :param model: PyTorch model.
  :param feature_extractor: PyTorch feature extractor.
  :param optimizer: PyTorch optimizer.
  :param criterion: loss function.
  :param temp: Supervised contrastive temperature.
  :param base_temp: Supervised contrastive base temperature.
  :param same_task_neg: Option to remove negative samples of different tasks.
  :param mem_size: int       : Fixed memory size
  :param batch_size_mem: int : Size of the batch sampled from the buffer
  :param train_mb_size: mini-batch size for training.
  :param train_epochs: number of training epochs.
  :param eval_mb_size: mini-batch size for eval.
  :param device: PyTorch device where the model will be allocated.
  :param plugins: (optional) list of StrategyPlugins.
  :param evaluator: (optional) instance of EvaluationPlugin for logging
      and metric computations. None to remove logging.
  :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').
docstr_tok: [":","param","model",":","PyTorch","model",".",":","param","feature_extractor",":","PyTorch","feature","extractor",".",":","param","optimizer",":","PyTorch","optimizer",".",":","param","criterion",":","loss","function",".",":","param","temp",":","Supervised","contrastive","temperature",".",":","param","base_temp",":","Supervised","contrastive","base","temperature",".",":","param","same_task_neg",":","Option","to","remove","negative","samples","of","different","tasks",".",":","param","mem_size",":","int",":","Fixed","memory","size",":","param","batch_size_mem",":","int",":","Size","of","the","batch","sampled","from","the","buffer",":","param","train_mb_size",":","mini-batch","size","for","training",".",":","param","train_epochs",":","number","of","training","epochs",".",":","param","eval_mb_size",":","mini-batch","size","for","eval",".",":","param","device",":","PyTorch","device","where","the","model","will","be","allocated",".",":","param","plugins",":","(","optional",")","list","of","StrategyPlugins",".",":","param","evaluator",":","(","optional",")","instance","of","EvaluationPlugin","for","logging","and","metric","computations",".","None","to","remove","logging",".",":","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","'",")","."]
code: def __init__(
      self,
      model: Module,
      feature_extractor: Module,
      optimizer: Optimizer,
      criterion=CrossEntropyLoss(),
      temp: float = 0.1,
      base_temp: float = 0.07,
      same_task_neg: bool = True,
      mem_size: int = 200,
      batch_size_mem: int = 10,
      train_mb_size: int = 1,
      train_epochs: int = 1,
      eval_mb_size: Optional[int] = 1,
      device: Union[str, torch.device] = "cpu",
      plugins: Optional[List[SupervisedPlugin]] = None,
      evaluator: Union[
          EvaluationPlugin, Callable[[], EvaluationPlugin]
      ] = default_evaluator,
      eval_every=-1,
      peval_mode="epoch",
  ):
      """
      :param model: PyTorch model.
      :param feature_extractor: PyTorch feature extractor.
      :param optimizer: PyTorch optimizer.
      :param criterion: loss function.
      :param temp: Supervised contrastive temperature.
      :param base_temp: Supervised contrastive base temperature.
      :param same_task_neg: Option to remove negative samples of different tasks.
      :param mem_size: int       : Fixed memory size
      :param batch_size_mem: int : Size of the batch sampled from the buffer
      :param train_mb_size: mini-batch size for training.
      :param train_epochs: number of training epochs.
      :param eval_mb_size: mini-batch size for eval.
      :param device: PyTorch device where the model will be allocated.
      :param plugins: (optional) list of StrategyPlugins.
      :param evaluator: (optional) instance of EvaluationPlugin for logging
          and metric computations. None to remove logging.
      :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').
      """
      super().__init__(
          model,
          optimizer,
          criterion,
          train_mb_size,
          train_epochs,
          eval_mb_size,
          device,
          plugins,
          evaluator,
          eval_every,
          peval_mode,
      )
      self.mem_size = mem_size
      self.batch_size_mem = batch_size_mem
      self.storage_policy = ClassBalancedBuffer(
          max_size=self.mem_size, adaptive_size=True
      )
      self.replay_loader = None
      self.aml_criterion = AMLCriterion(
          feature_extractor=feature_extractor,
          temp=temp,
          base_temp=base_temp,
          same_task_neg=same_task_neg,
          device=device,
      )
  
file_path: avalanche/avalanche/training/supervised/er_aml.py
imports: from typing import Callable, List, Optional, Union
  import torch
  from torch.nn import CrossEntropyLoss, Module
  from torch.optim import Optimizer
  from avalanche.core import SupervisedPlugin
  from avalanche.models.utils import avalanche_forward
  from avalanche.training import AMLCriterion
  from avalanche.training.plugins.evaluation import EvaluationPlugin, default_evaluator
  from avalanche.training.storage_policy import ClassBalancedBuffer
  from avalanche.training.templates import SupervisedTemplate
  from avalanche.training.utils import cycle
label_desc: Use image node_id 1 to create a new ER_AML object from inherited base classes: SupervisedTemplate with example: obj = ER_AML(model, feature_extractor, optimizer, criterion, temp, base_temp, same_task_neg, mem_size, batch_size_mem, train_mb_size, train_epochs, eval_mb_size, device, plugins, evaluator, eval_every, peval_mode)