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: Transform the dictionary of {class_id: mean vector}
  into a tensor of shape (num_classes, feature_size), where
  `feature_size` is the size of the mean vector.
  The `num_classes` parameter is the maximum class_id found
  in the dictionary. Missing class means are treated as zero vectors.
docstr_tok: ["Transform","the","dictionary","of","{","class_id",":","mean","vector","}","into","a","tensor","of","shape","(","num_classes",",","feature_size",")",",","where","`","feature_size","`","is","the","size","of","the","mean","vector",".","The","`","num_classes","`","parameter","is","the","maximum","class_id","found","in","the","dictionary",".","Missing","class","means","are","treated","as","zero","vectors","."]
code: def _vectorize_means_dict(self):
      """
      Transform the dictionary of {class_id: mean vector}
      into a tensor of shape (num_classes, feature_size), where
      `feature_size` is the size of the mean vector.
      The `num_classes` parameter is the maximum class_id found
      in the dictionary. Missing class means are treated as zero vectors.
      """
      if self.class_means_dict == {}:
          return
  
      max_class = max(self.class_means_dict.keys())
      self.max_class = max(max_class, self.max_class)
      first_mean = list(self.class_means_dict.values())[0]
      feature_size = first_mean.size(0)
      device = first_mean.device
      self.class_means = torch.zeros(
          self.max_class + 1, feature_size
      ).to(device)
  
      for k, v in self.class_means_dict.items():
          self.class_means[k] = self.class_means_dict[k].clone()
  
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 3 for calling the NCMClassifier obj's underlying member method code with example usage: obj._vectorize_means_dict() without return types