class_docstr: GSSPlugin replay plugin.
  
  Code adapted from the repository:
  https://github.com/RaptorMai/online-continual-learning
  Handles an external memory fulled with samples selected
  using the Greedy approach of GSS algorithm.
  `before_forward` callback is used to process the current
  sample and estimate a score.
docstr: Args:
      buffer: memory buffer
      grad_dims: gradient dimensions
      mem_grads: gradient from memory subsets
      batch_x: batch images
      batch_y: batch labels
  Returns: score of each sample from current batch
docstr_tok: ["Args",":","buffer",":","memory","buffer","grad_dims",":","gradient","dimensions","mem_grads",":","gradient","from","memory","subsets","batch_x",":","batch","images","batch_y",":","batch","labels","Returns",":","score","of","each","sample","from","current","batch"]
code: def get_each_batch_sample_sim(
      self, strategy, grad_dims, mem_grads, batch_x, batch_y
  ):
      """
      Args:
          buffer: memory buffer
          grad_dims: gradient dimensions
          mem_grads: gradient from memory subsets
          batch_x: batch images
          batch_y: batch labels
      Returns: score of each sample from current batch
      """
      cosine_sim = torch.zeros(batch_x.size(0), device=strategy.device)
      for i, (x, y) in enumerate(zip(batch_x, batch_y)):
          strategy.model.zero_grad()
          ptloss = strategy._criterion(
              strategy.model.forward(x.unsqueeze(0)), y.unsqueeze(0)
          )
          ptloss.backward()
          # add the new grad to the memory grads and add it is cosine
          # similarity
          this_grad = self.get_grad_vector(
              strategy.model.parameters, grad_dims
          ).unsqueeze(0)
          cosine_sim[i] = max(
              self.cosine_similarity(mem_grads, this_grad)
          )
      return cosine_sim
  
file_path: avalanche/avalanche/training/plugins/gss_greedy.py
imports: from typing import TYPE_CHECKING
  import torch
  from avalanche.benchmarks.utils import _make_taskaware_classification_dataset
  from avalanche.benchmarks.utils.data_loader import ReplayDataLoader
  from avalanche.training.plugins.strategy_plugin import SupervisedPlugin
label_desc: Use image node_id 7 for calling the GSS_greedyPlugin obj's underlying member method code with example usage: obj.get_each_batch_sample_sim(strategy, grad_dims, mem_grads, batch_x, batch_y) and returns: cosine_sim