def forward(self, inputs: torch.Tensor) -> torch.Tensor:
        """Generate anomaly maps from z-distributions.

        Args:
            inputs (torch.Tensor): List of z-distributions from different scales,
                where each element has shape ``(batch_size, channels, height,
                width)``.

        Returns:
            torch.Tensor: Anomaly maps with shape ``(batch_size, 1, height,
                width)``, where height and width match the input dimensions.

        Example:
            >>> z_dist = [torch.randn(2, 64, 32, 32) for _ in range(3)]
            >>> generator = AnomalyMapGenerator((3, 256, 256))
            >>> maps = generator(z_dist)
            >>> maps.shape
            torch.Size([2, 1, 256, 256])
        """
        anomaly_map: torch.Tensor
        if self.mode == AnomalyMapMode.ALL:
            anomaly_map = torch.ones(inputs[0].shape[0], 1, *self.input_dims[1:]).to(inputs[0].device)
            for z_dist in inputs:
                mean_z = (z_dist**2).mean(dim=1, keepdim=True)
                anomaly_map *= F.interpolate(
                    mean_z,
                    size=self.input_dims[1:],
                    mode="bilinear",
                    align_corners=False,
                )
        else:
            mean_z = (inputs[0] ** 2).mean(dim=1, keepdim=True)
            anomaly_map = F.interpolate(
                mean_z,
                size=self.input_dims[1:],
                mode="bilinear",
                align_corners=False,
            )

        return anomaly_map
Generate anomaly maps from z-distributions.

        Args:
            inputs (torch.Tensor): List of z-distributions from different scales,
                where each element has shape ``(batch_size, channels, height,
                width)``.

        Returns:
            torch.Tensor: Anomaly maps with shape ``(batch_size, 1, height,
                width)``, where height and width match the input dimensions.

        Example:
            >>> z_dist = [torch.randn(2, 64, 32, 32) for _ in range(3)]
            >>> generator = AnomalyMapGenerator((3, 256, 256))
            >>> maps = generator(z_dist)
            >>> maps.shape
            torch.Size([2, 1, 256, 256])
        
src/anomalib/models/image/csflow/anomaly_map.py