def compute_anomaly_map(
        self,
        teacher_features: dict[str, torch.Tensor],
        student_features: dict[str, torch.Tensor],
        image_size: tuple[int, int] | torch.Size,
    ) -> torch.Tensor:
        """Compute overall anomaly map by combining multiple layer maps.

        The final anomaly map is generated by:
        1. Computing per-layer anomaly maps via :func:`compute_layer_map`
        2. Combining layer maps through element-wise multiplication

        Args:
            teacher_features (dict[str, torch.Tensor]): Dictionary mapping layer
                names to teacher feature tensors
            student_features (dict[str, torch.Tensor]): Dictionary mapping layer
                names to student feature tensors
            image_size (tuple[int, int] | torch.Size): Target size for the
                anomaly map in format ``(H, W)``

        Returns:
            torch.Tensor: Final anomaly map with shape ``(B, 1, H, W)`` where
                ``B`` is batch size and ``(H, W)`` matches ``image_size``
        """
        batch_size = next(iter(teacher_features.values())).shape[0]
        anomaly_map = torch.ones(batch_size, 1, image_size[0], image_size[1])
        for layer in teacher_features:
            layer_map = self.compute_layer_map(teacher_features[layer], student_features[layer], image_size)
            anomaly_map = anomaly_map.to(layer_map.device)
            anomaly_map *= layer_map

        return anomaly_map
Compute overall anomaly map by combining multiple layer maps.

        The final anomaly map is generated by:
        1. Computing per-layer anomaly maps via :func:`compute_layer_map`
        2. Combining layer maps through element-wise multiplication

        Args:
            teacher_features (dict[str, torch.Tensor]): Dictionary mapping layer
                names to teacher feature tensors
            student_features (dict[str, torch.Tensor]): Dictionary mapping layer
                names to student feature tensors
            image_size (tuple[int, int] | torch.Size): Target size for the
                anomaly map in format ``(H, W)``

        Returns:
            torch.Tensor: Final anomaly map with shape ``(B, 1, H, W)`` where
                ``B`` is batch size and ``(H, W)`` matches ``image_size``
        
src/anomalib/models/image/stfpm/anomaly_map.py