class_docstr: Supervised Contrastive Replay from https://arxiv.org/pdf/2103.13885.pdf.
  This strategy trains an encoder network in a self-supervised manner to
  cluster together examples of the same class while pushing away examples
  of different classes. It uses the Nearest Class Mean classifier on the
  embeddings produced by the encoder.
  
  Accuracy cannot be monitored during training (no NCM classifier).
  During training, NCRLoss is monitored, while during eval
  CrossEntropyLoss is monitored.
  
  The original paper uses an additional fine-tuning phase on the buffer
  at the end of each experience (called review trick, but not mentioned
  in the paper). This implementation does not implement the review trick.
class_docstr_tok: ["Supervised","Contrastive","Replay","from","https",":","\/\/arxiv.org\/pdf\/2103.13885.pdf",".","This","strategy","trains","an","encoder","network","in","a","self-supervised","manner","to","cluster","together","examples","of","the","same","class","while","pushing","away","examples","of","different","classes",".","It","uses","the","Nearest","Class","Mean","classifier","on","the","embeddings","produced","by","the","encoder",".","Accuracy","can","not","be","monitored","during","training","(","no","NCM","classifier",")",".","During","training",",","NCRLoss","is","monitored",",","while","during","eval","CrossEntropyLoss","is","monitored",".","The","original","paper","uses","an","additional","fine-tuning","phase","on","the","buffer","at","the","end","of","each","experience","(","called","review","trick",",","but","not","mentioned","in","the","paper",")",".","This","implementation","does","not","implement","the","review","trick","."]
docstr: Concatenate together original and augmented examples.
docstr_tok: ["Concatenate","together","original","and","augmented","examples","."]
code: def _before_forward(self, **kwargs):
      """
      Concatenate together original and augmented examples.
      """
      assert self.is_training
      super()._before_forward(**kwargs)
      mb_x_augmented = self.augmentations(self.mbatch[0])
      # (batch_size*2, input_size)
      self.mbatch[0] = torch.cat(
          [self.mbatch[0], mb_x_augmented], dim=0
      )
  
imports: from typing import Optional, Sequence
  import torch
  from torch.nn import Module
  from torch.optim import Optimizer
  from torch.utils.data import DataLoader
  from torchvision.transforms import Compose, Lambda
  from avalanche.core import BaseSGDPlugin
  from avalanche.models import SCRModel
  from avalanche.training.losses import SCRLoss
  from avalanche.training.plugins import ReplayPlugin
  from avalanche.training.plugins.evaluation import default_evaluator
  from avalanche.training.storage_policy import ClassBalancedBuffer
  from avalanche.training.templates import SupervisedTemplate
label_desc: Use image node_id 3 for calling the SCR obj's underlying member method code with example usage: obj._before_forward() without return types