class_docstr: NCM Classifier.
  NCMClassifier performs nearest class mean classification
  measuring the distance between the input tensor and the
  ones stored in 'self.class_means'.
  
  Before being used for inference, NCMClassifier needs to
  be updated with a mean vector per class, by calling
  `update_class_means_dict`.
  
  This class registers a `class_means` buffer that stores
  the class means in a single tensor of shape
  [max_class_id_seen, feature_size]. Classes with ID smaller
  than `max_class_id_seen` are associated with a 0-vector.
docstr: :param x: (batch_size, feature_size)
  
  Returns a tensor of size (batch_size, num_classes) with
  negative distance of each element in the mini-batch
  with respect to each class.
docstr_tok: [":","param","x",":","(","batch_size",",","feature_size",")","Returns","a","tensor","of","size","(","batch_size",",","num_classes",")","with","negative","distance","of","each","element","in","the","mini-batch","with","respect","to","each","class","."]
code: def forward(self, x):
      """
      :param x: (batch_size, feature_size)
  
      Returns a tensor of size (batch_size, num_classes) with
      negative distance of each element in the mini-batch
      with respect to each class.
      """
      if self.class_means_dict == {}:
          self.init_missing_classes(
              range(self.max_class + 1), x.shape[1], x.device
          )
  
      assert self.class_means_dict != {}, "no class means available."
      if self.normalize:
          # normalize across feature_size
          x = (x.T / torch.norm(x.T, dim=0)).T
  
      # (num_classes, batch_size)
      sqd = torch.cdist(self.class_means.to(x.device), x)
      # (batch_size, num_classes)
      return (-sqd).T
  
file_path: avalanche/avalanche/models/ncm_classifier.py
imports: from typing import Dict
  import torch
  from torch import Tensor, nn
  from avalanche.models import DynamicModule
label_desc: Use image node_id 4 for calling the NCMClassifier obj's underlying member method code with example usage: obj.forward(x) and returns: unknown