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

        Validates and normalizes input mask arrays.

        Args:
            mask (``np.ndarray`` | ``None``): Input ground truth mask.

        Returns:
            ``np.ndarray`` | ``None``: Validated mask as boolean array, or None.

        Raises:
            TypeError: If ``mask`` is not a numpy array.
            ValueError: If ``mask`` dimensions are invalid.

        Example:
            Validate a binary mask::

                >>> import numpy as np
                >>> from anomalib.data.validators import NumpyImageValidator
                >>> mask = np.random.randint(0, 2, (224, 224))
                >>> validated_mask = NumpyImageValidator.validate_gt_mask(mask)
                >>> validated_mask.shape
                (224, 224)

        Note:
            - 3D masks with shape (H,W,1) are squeezed to (H,W)
            - Output is always boolean type
            - None inputs return None
        """
        if mask is None:
            return None
        if not isinstance(mask, np.ndarray):
            msg = f"Mask must be a numpy.ndarray, got {type(mask)}."
            raise TypeError(msg)
        if mask.ndim not in {2, 3}:
            msg = f"Mask must have shape [H, W] or [H, W, 1] got shape {mask.shape}."
            raise ValueError(msg)
        if mask.ndim == 3:
            if mask.shape[2] != 1:
                msg = f"Mask must have 1 channel, got {mask.shape[2]}."
                raise ValueError(msg)
            mask = mask.squeeze(2)
        return mask.astype(bool)
Validate the ground truth mask.

        Validates and normalizes input mask arrays.

        Args:
            mask (``np.ndarray`` | ``None``): Input ground truth mask.

        Returns:
            ``np.ndarray`` | ``None``: Validated mask as boolean array, or None.

        Raises:
            TypeError: If ``mask`` is not a numpy array.
            ValueError: If ``mask`` dimensions are invalid.

        Example:
            Validate a binary mask::

                >>> import numpy as np
                >>> from anomalib.data.validators import NumpyImageValidator
                >>> mask = np.random.randint(0, 2, (224, 224))
                >>> validated_mask = NumpyImageValidator.validate_gt_mask(mask)
                >>> validated_mask.shape
                (224, 224)

        Note:
            - 3D masks with shape (H,W,1) are squeezed to (H,W)
            - Output is always boolean type
            - None inputs return None
        
src/anomalib/data/validators/numpy/image.py