def validate_anomaly_map(anomaly_map: torch.Tensor | None) -> Mask | None:
        """Validate the anomaly maps for a batch.

        Validates that the input anomaly maps have the correct shape and format.
        Converts maps to float32 type.

        Args:
            anomaly_map (torch.Tensor | None): Input anomaly maps. Should be either:
                - Shape ``(B,T,H,W)`` for single channel maps
                - Shape ``(B,T,1,H,W)`` for explicit single channel
                Where:
                    - ``B`` is batch size
                    - ``T`` is number of frames
                    - ``H`` is height
                    - ``W`` is width

        Returns:
            Mask | None: Validated anomaly maps as float32 tensor.

        Raises:
            TypeError: If ``anomaly_map`` is not a ``torch.Tensor``.
            ValueError: If anomaly map shape is invalid.

        Examples:
            >>> import torch
            >>> from anomalib.data.validators import VideoBatchValidator
            >>> # Create maps for 2 videos with 10 frames each
            >>> anomaly_maps = torch.rand(2, 10, 224, 224)
            >>> validated_maps = VideoBatchValidator.validate_anomaly_map(anomaly_maps)
            >>> print(validated_maps.shape)
            torch.Size([2, 10, 224, 224])
        """
        if anomaly_map is None:
            return None
        if not isinstance(anomaly_map, torch.Tensor):
            msg = f"Anomaly maps must be a torch.Tensor, got {type(anomaly_map)}."
            raise TypeError(msg)
        if anomaly_map.ndim not in {4, 5}:
            msg = f"Anomaly maps must have shape [B, T, H, W] or [B, T, 1, H, W], got shape {anomaly_map.shape}."
            raise ValueError(msg)
        if anomaly_map.ndim == 5:
            if anomaly_map.shape[2] != 1:
                msg = f"Anomaly maps must have 1 channel, got {anomaly_map.shape[2]}."
                raise ValueError(msg)
            anomaly_map = anomaly_map.squeeze(2)
        return Mask(anomaly_map, dtype=torch.float32)
Validate the anomaly maps for a batch.

        Validates that the input anomaly maps have the correct shape and format.
        Converts maps to float32 type.

        Args:
            anomaly_map (torch.Tensor | None): Input anomaly maps. Should be either:
                - Shape ``(B,T,H,W)`` for single channel maps
                - Shape ``(B,T,1,H,W)`` for explicit single channel
                Where:
                    - ``B`` is batch size
                    - ``T`` is number of frames
                    - ``H`` is height
                    - ``W`` is width

        Returns:
            Mask | None: Validated anomaly maps as float32 tensor.

        Raises:
            TypeError: If ``anomaly_map`` is not a ``torch.Tensor``.
            ValueError: If anomaly map shape is invalid.

        Examples:
            >>> import torch
            >>> from anomalib.data.validators import VideoBatchValidator
            >>> # Create maps for 2 videos with 10 frames each
            >>> anomaly_maps = torch.rand(2, 10, 224, 224)
            >>> validated_maps = VideoBatchValidator.validate_anomaly_map(anomaly_maps)
            >>> print(validated_maps.shape)
            torch.Size([2, 10, 224, 224])
        
src/anomalib/data/validators/torch/video.py