class_docstr: Generate Anomaly Heatmap.
  
  Args:
      image_size (ListConfig, tuple): Size of the input image. The anomaly map is upsampled to this dimension.
      sigma (int, optional): Standard deviation for Gaussian Kernel. Defaults to 4.
docstr: Compute anomaly score to the patch in position(i,j) of a test image.
  
  Ref: Equation (2), Section III-C of the paper.
  
  Args:
      embedding (Tensor): Embedding Vector
      stats (list[Tensor]): Mean and Covariance Matrix of the multivariate Gaussian distribution
  
  Returns:
      Anomaly score of a test image via mahalanobis distance.
docstr_tok: ["Compute","anomaly","score","to","the","patch","in","position","(","i",",","j",")","of","a","test","image",".","Ref",":","Equation","(","2",")",",","Section","III-C","of","the","paper",".","Args",":","embedding","(","Tensor",")",":","Embedding","Vector","stats","(","list","[","Tensor","]",")",":","Mean","and","Covariance","Matrix","of","the","multivariate","Gaussian","distribution","Returns",":","Anomaly","score","of","a","test","image","via","mahalanobis","distance","."]
code: def compute_distance(
      embedding: Tensor, stats: list[Tensor]
  ) -> Tensor:
      """Compute anomaly score to the patch in position(i,j) of a test image.
  
      Ref: Equation (2), Section III-C of the paper.
  
      Args:
          embedding (Tensor): Embedding Vector
          stats (list[Tensor]): Mean and Covariance Matrix of the multivariate Gaussian distribution
  
      Returns:
          Anomaly score of a test image via mahalanobis distance.
      """
  
      batch, channel, height, width = embedding.shape
      embedding = embedding.reshape(batch, channel, height * width)
  
      # calculate mahalanobis distances
      mean, inv_covariance = stats
      delta = (embedding - mean).permute(2, 0, 1)
  
      distances = (
          (torch.matmul(delta, inv_covariance) * delta)
          .sum(2)
          .permute(1, 0)
      )
      distances = distances.reshape(batch, 1, height, width)
      distances = distances.clamp(0).sqrt()
  
      return distances
  
file_path: anomalib/src/anomalib/models/padim/anomaly_map.py
imports: from __future__ import annotations
  import torch
  import torch.nn.functional
  from omegaconf import ListConfig
  from torch import Tensor, nn
  from anomalib.models.components import GaussianBlur2d
label_desc: Use image node_id 2 for calling the AnomalyMapGenerator obj's underlying member method code with example usage: obj.compute_distance(embedding, stats) and returns: distances