class_docstr: FeCAMClassifier
  
  Similar to NCM but uses malahanobis distance instead of l2 distance
  
  This approach has been proposed for continual learning in
  "FeCAM: Exploiting the Heterogeneity of Class Distributions
  in Exemplar-Free Continual Learning" Goswami et. al.
  (Neurips 2023)
  
  This requires the storage of full per-class covariance matrices
code: def _mahalanobis(self, vectors, class_means, cov):
      x_minus_mu = F.normalize(vectors, p=2, dim=-1) - F.normalize(
          class_means, p=2, dim=-1
      )
      inv_covmat = torch.linalg.pinv(cov).float().to(vectors.device)
      left_term = torch.matmul(x_minus_mu, inv_covmat)
      mahal = torch.matmul(left_term, x_minus_mu.T)
      return torch.diagonal(mahal, 0)
  
imports: import copy
  from typing import Dict
  import numpy
  import torch
  import torch.nn.functional
  import tqdm
  from torch import Tensor, nn
  from avalanche.models import DynamicModule
label_desc: Use image node_id 3 for calling the FeCAMClassifier obj's underlying member method code with example usage: obj._mahalanobis(vectors, class_means, cov) and returns: torch