def validate_pred_score(pred_score: np.ndarray | None) -> np.ndarray | None:
        """Validate the prediction scores for a batch.

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

        Args:
            pred_score (``np.ndarray`` | ``None``): Input prediction score batch.

        Returns:
            ``np.ndarray`` | ``None``: Validated prediction score batch, or ``None``.

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

        Examples:
            Validate 1D scores::

                >>> scores = np.array([0.1, 0.8, 0.3, 0.6])
                >>> validated = NumpyImageBatchValidator.validate_pred_score(scores)
                >>> validated
                array([0.1, 0.8, 0.3, 0.6], dtype=float32)

            Validate 2D scores::

                >>> scores = np.array([[0.1], [0.8], [0.3], [0.6]])
                >>> validated = NumpyImageBatchValidator.validate_pred_score(scores)
                >>> validated
                array([[0.1],
                       [0.8],
                       [0.3],
                       [0.6]], dtype=float32)
        """
        if pred_score is None:
            return None
        if not isinstance(pred_score, np.ndarray):
            msg = f"Prediction score batch must be a numpy.ndarray, got {type(pred_score)}."
            raise TypeError(msg)
        if pred_score.ndim not in {1, 2}:
            msg = f"Prediction score batch must be 1D or 2D, got shape {pred_score.shape}."
            raise ValueError(msg)

        return pred_score.astype(np.float32)
Validate the prediction scores for a batch.

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

        Args:
            pred_score (``np.ndarray`` | ``None``): Input prediction score batch.

        Returns:
            ``np.ndarray`` | ``None``: Validated prediction score batch, or ``None``.

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

        Examples:
            Validate 1D scores::

                >>> scores = np.array([0.1, 0.8, 0.3, 0.6])
                >>> validated = NumpyImageBatchValidator.validate_pred_score(scores)
                >>> validated
                array([0.1, 0.8, 0.3, 0.6], dtype=float32)

            Validate 2D scores::

                >>> scores = np.array([[0.1], [0.8], [0.3], [0.6]])
                >>> validated = NumpyImageBatchValidator.validate_pred_score(scores)
                >>> validated
                array([[0.1],
                       [0.8],
                       [0.3],
                       [0.6]], dtype=float32)
        
src/anomalib/data/validators/numpy/image.py