def validate_pred_label(pred_label: np.ndarray | None) -> np.ndarray | None:
        """Validate the prediction label batch.

        This method validates batches of prediction labels. It handles:
            - 1D and 2D arrays
            - Type conversion to boolean
            - Shape validation

        Args:
            pred_label (``np.ndarray`` | ``None``): Input prediction label batch.

        Returns:
            ``np.ndarray`` | ``None``: Validated prediction label batch as boolean array,
                or ``None``.

        Raises:
            TypeError: If ``pred_label`` is not a numpy array.
            ValueError: If ``pred_label`` shape is invalid.

        Examples:
            Validate 1D labels::

                >>> labels = np.array([0, 1, 1, 0])
                >>> validated = NumpyImageBatchValidator.validate_pred_label(labels)
                >>> validated
                array([False,  True,  True, False])

            Validate 2D labels::

                >>> labels = np.array([[0], [1], [1], [0]])
                >>> validated = NumpyImageBatchValidator.validate_pred_label(labels)
                >>> validated
                array([[False],
                       [ True],
                       [ True],
                       [False]])
        """
        if pred_label is None:
            return None
        if not isinstance(pred_label, np.ndarray):
            msg = f"Prediction label batch must be a numpy.ndarray, got {type(pred_label)}."
            raise TypeError(msg)
        if pred_label.ndim not in {1, 2}:
            msg = f"Prediction label batch must be 1D or 2D, got shape {pred_label.shape}."
            raise ValueError(msg)
        return pred_label.astype(bool)
Validate the prediction label batch.

        This method validates batches of prediction labels. It handles:
            - 1D and 2D arrays
            - Type conversion to boolean
            - Shape validation

        Args:
            pred_label (``np.ndarray`` | ``None``): Input prediction label batch.

        Returns:
            ``np.ndarray`` | ``None``: Validated prediction label batch as boolean array,
                or ``None``.

        Raises:
            TypeError: If ``pred_label`` is not a numpy array.
            ValueError: If ``pred_label`` shape is invalid.

        Examples:
            Validate 1D labels::

                >>> labels = np.array([0, 1, 1, 0])
                >>> validated = NumpyImageBatchValidator.validate_pred_label(labels)
                >>> validated
                array([False,  True,  True, False])

            Validate 2D labels::

                >>> labels = np.array([[0], [1], [1], [0]])
                >>> validated = NumpyImageBatchValidator.validate_pred_label(labels)
                >>> validated
                array([[False],
                       [ True],
                       [ True],
                       [False]])
        
src/anomalib/data/validators/numpy/image.py