def validate_anomaly_map(anomaly_map: np.ndarray | None) -> np.ndarray | None:
        """Validate the anomaly map.

        Args:
            anomaly_map (``np.ndarray`` | ``None``): Input anomaly map to validate.

        Returns:
            ``np.ndarray`` | ``None``: Validated anomaly map as float32 numpy array, or
                None if input is None.

        Raises:
            TypeError: If ``anomaly_map`` is not a numpy array.
            ValueError: If ``anomaly_map`` dimensions or channel count are invalid.

        Example:
            >>> import numpy as np
            >>> validator = NumpyVideoValidator()
            >>> amap = np.random.rand(5, 224, 224)  # [T, H, W]
            >>> validated_amap = validator.validate_anomaly_map(amap)
            >>> print(validated_amap.shape, validated_amap.dtype)
            (5, 224, 224) float32
        """
        if anomaly_map is None:
            return None
        if not isinstance(anomaly_map, np.ndarray):
            msg = f"Anomaly map must be a numpy.ndarray, got {type(anomaly_map)}."
            raise TypeError(msg)
        if anomaly_map.ndim not in {3, 4}:
            msg = f"Anomaly map must have shape [T, H, W] or [T, H, W, 1], got shape {anomaly_map.shape}."
            raise ValueError(msg)
        if anomaly_map.ndim == 4 and anomaly_map.shape[3] != 1:
            msg = f"Anomaly map must have 1 channel, got {anomaly_map.shape[3]}."
            raise ValueError(msg)
        return anomaly_map.astype(np.float32)
Validate the anomaly map.

        Args:
            anomaly_map (``np.ndarray`` | ``None``): Input anomaly map to validate.

        Returns:
            ``np.ndarray`` | ``None``: Validated anomaly map as float32 numpy array, or
                None if input is None.

        Raises:
            TypeError: If ``anomaly_map`` is not a numpy array.
            ValueError: If ``anomaly_map`` dimensions or channel count are invalid.

        Example:
            >>> import numpy as np
            >>> validator = NumpyVideoValidator()
            >>> amap = np.random.rand(5, 224, 224)  # [T, H, W]
            >>> validated_amap = validator.validate_anomaly_map(amap)
            >>> print(validated_amap.shape, validated_amap.dtype)
            (5, 224, 224) float32
        
src/anomalib/data/validators/numpy/video.py