def validate_gt_mask(gt_mask: np.ndarray | None) -> np.ndarray | None:
        """Validate the ground truth mask batch.

        Args:
            gt_mask (``np.ndarray`` | ``None``): Input ground truth mask batch to validate.

        Returns:
            ``np.ndarray`` | ``None``: Validated ground truth mask batch as boolean numpy
                array, or None if input is None.

        Raises:
            TypeError: If the input is not a numpy array.
            ValueError: If the mask batch shape is invalid.

        Example:
            >>> import numpy as np
            >>> validator = NumpyVideoBatchValidator()
            >>> masks = np.random.randint(0, 2, size=(2, 5, 224, 224))  # [N, T, H, W]
            >>> validated_masks = validator.validate_gt_mask(masks)
            >>> print(validated_masks.shape, validated_masks.dtype)
            (2, 5, 224, 224) bool
        """
        if gt_mask is None:
            return None
        if not isinstance(gt_mask, np.ndarray):
            msg = f"Ground truth mask batch must be a numpy.ndarray, got {type(gt_mask)}."
            raise TypeError(msg)
        if gt_mask.ndim not in {4, 5}:
            msg = f"Ground truth mask batch must have shape [N, T, H, W] or [N, T, H, W, 1], got shape {gt_mask.shape}."
            raise ValueError(msg)
        if gt_mask.ndim == 5 and gt_mask.shape[4] != 1:
            msg = f"Ground truth mask batch must have 1 channel, got {gt_mask.shape[4]}."
            raise ValueError(msg)
        return gt_mask.astype(bool)
Validate the ground truth mask batch.

        Args:
            gt_mask (``np.ndarray`` | ``None``): Input ground truth mask batch to validate.

        Returns:
            ``np.ndarray`` | ``None``: Validated ground truth mask batch as boolean numpy
                array, or None if input is None.

        Raises:
            TypeError: If the input is not a numpy array.
            ValueError: If the mask batch shape is invalid.

        Example:
            >>> import numpy as np
            >>> validator = NumpyVideoBatchValidator()
            >>> masks = np.random.randint(0, 2, size=(2, 5, 224, 224))  # [N, T, H, W]
            >>> validated_masks = validator.validate_gt_mask(masks)
            >>> print(validated_masks.shape, validated_masks.dtype)
            (2, 5, 224, 224) bool
        
src/anomalib/data/validators/numpy/video.py