class_docstr: Implements the DER and the DER++ Strategy,
  from the "Dark Experience For General Continual Learning"
  paper, Buzzega et. al, https://arxiv.org/abs/2004.07211
class_docstr_tok: ["Implements","the","DER","and","the","DER++","Strategy",",","from","the","``","Dark","Experience","For","General","Continual","Learning","''","paper",",","Buzzega","et",".","al",",","https",":","\/\/arxiv.org\/abs\/2004.07211"]
docstr: Training epoch.
  
  :param kwargs:
  :return:
docstr_tok: ["Training","epoch",".",":","param","kwargs",":",":","return",":"]
code: def training_epoch(self, **kwargs):
      """Training epoch.
  
      :param kwargs:
      :return:
      """
      for self.mbatch in self.dataloader:
          if self._stop_training:
              break
  
          self._unpack_minibatch()
          self._before_training_iteration(**kwargs)
  
          self.optimizer.zero_grad()
          self.loss = self._make_empty_loss()
  
          # Forward
          self._before_forward(**kwargs)
          self.mb_output = self.forward()
          self._after_forward(**kwargs)
  
          if self.replay_loader is not None:
              # DER Loss computation
  
              self.loss += F.cross_entropy(
                  self.mb_output[self.batch_size_mem :],
                  self.mb_y[self.batch_size_mem :],
              )
  
              self.loss += self.alpha * F.mse_loss(
                  self.mb_output[: self.batch_size_mem],
                  self.batch_logits,
              )
              self.loss += self.beta * F.cross_entropy(
                  self.mb_output[: self.batch_size_mem],
                  self.mb_y[: self.batch_size_mem],
              )
  
              # They are a few difference compared to the autors impl:
              # - Joint forward pass vs. 3 forward passes
              # - One replay batch vs two replay batches
              # - Logits are stored from the non-transformed sample
              #   after training on task vs instantly on transformed sample
  
          else:
              self.loss += self.criterion()
  
          self._before_backward(**kwargs)
          self.backward()
          self._after_backward(**kwargs)
  
          # Optimization step
          self._before_update(**kwargs)
          self.optimizer_step()
          self._after_update(**kwargs)
  
          self._after_training_iteration(**kwargs)
  
imports: from collections import defaultdict
  from typing import Callable, Dict, List, Optional, Sequence, Set, SupportsInt, Union
  import torch
  import torch.nn.functional
  from torch.nn import CrossEntropyLoss, Module
  from torch.optim import Optimizer
  from avalanche.benchmarks.utils import make_avalanche_dataset
  from avalanche.benchmarks.utils.data import AvalancheDataset
  from avalanche.benchmarks.utils.data_attribute import TensorDataAttribute
  from avalanche.training.utils import cycle
  from avalanche.core import SupervisedPlugin
  from avalanche.training.plugins.evaluation import EvaluationPlugin, default_evaluator
  from avalanche.training.storage_policy import BalancedExemplarsBuffer, ReservoirSamplingBuffer
  from avalanche.training.templates import SupervisedTemplate
label_desc: Use image node_id 5 for calling the DER obj's underlying member method code with example usage: obj.training_epoch() without return types