def compute_anomaly_map(
        self,
        embedding: torch.Tensor,
        mean: torch.Tensor,
        inv_covariance: torch.Tensor,
        image_size: tuple[int, int] | torch.Size | None = None,
    ) -> torch.Tensor:
        """Compute anomaly map from feature embeddings and distribution parameters.

        This method combines distance computation, upsampling, and smoothing to
        generate the final anomaly map.

        Args:
            embedding (torch.Tensor): Feature embeddings from the CNN backbone
            mean (torch.Tensor): Mean of the multivariate Gaussian distribution
            inv_covariance (torch.Tensor): Inverse covariance matrix
            image_size (tuple[int, int] | torch.Size | None, optional): Target
                size for upsampling. If ``None``, no upsampling is performed.

        Returns:
            torch.Tensor: Final anomaly map after all processing steps
        """
        score_map = self.compute_distance(
            embedding=embedding,
            stats=[mean.to(embedding.device), inv_covariance.to(embedding.device)],
        )
        if image_size:
            score_map = self.up_sample(score_map, image_size)
        return self.smooth_anomaly_map(score_map)
Compute anomaly map from feature embeddings and distribution parameters.

        This method combines distance computation, upsampling, and smoothing to
        generate the final anomaly map.

        Args:
            embedding (torch.Tensor): Feature embeddings from the CNN backbone
            mean (torch.Tensor): Mean of the multivariate Gaussian distribution
            inv_covariance (torch.Tensor): Inverse covariance matrix
            image_size (tuple[int, int] | torch.Size | None, optional): Target
                size for upsampling. If ``None``, no upsampling is performed.

        Returns:
            torch.Tensor: Final anomaly map after all processing steps
        
src/anomalib/models/image/padim/anomaly_map.py