def compute_anomaly_map(
        self,
        score: torch.Tensor,
        image_size: tuple[int, int] | torch.Size | None = None,
    ) -> torch.Tensor:
        """Generate smoothed anomaly map from scores.

        Args:
            score (torch.Tensor): Anomaly scores of shape
                ``(batch_size, 1, height, width)``.
            image_size (tuple[int, int] | torch.Size | None, optional): Target
                size for upsampling the anomaly map. Defaults to ``None``.

        Returns:
            torch.Tensor: Smoothed anomaly map of shape
                ``(batch_size, 1, height, width)``.
        """
        anomaly_map = score.mean(dim=1, keepdim=True)
        if image_size is not None:
            anomaly_map = F.interpolate(anomaly_map, size=image_size, mode="bilinear", align_corners=False)

        gaussian_blur = GaussianBlur2d(sigma=self.sigma).to(score.device)
        return gaussian_blur(anomaly_map)  # pylint: disable=not-callable
Generate smoothed anomaly map from scores.

        Args:
            score (torch.Tensor): Anomaly scores of shape
                ``(batch_size, 1, height, width)``.
            image_size (tuple[int, int] | torch.Size | None, optional): Target
                size for upsampling the anomaly map. Defaults to ``None``.

        Returns:
            torch.Tensor: Smoothed anomaly map of shape
                ``(batch_size, 1, height, width)``.
        
src/anomalib/models/image/cfa/anomaly_map.py