def validate_pred_score(
        pred_score: torch.Tensor | np.ndarray | float | None,
    ) -> torch.Tensor | None:
        """Validate the prediction score.

        This method validates and normalizes prediction scores. It handles:
            - Float, numpy array and tensor inputs
            - Type conversion to float32
            - None inputs return None

        Args:
            pred_score (``torch.Tensor`` | ``np.ndarray`` | ``float`` | ``None``):
                Input prediction score.

        Returns:
            ``torch.Tensor`` | ``None``: Validated prediction score as a float32
                tensor, or None.

        Raises:
            TypeError: If ``pred_score`` cannot be converted to a tensor.
            ValueError: If ``pred_score`` is not a scalar.

        Example:
            >>> import torch
            >>> from anomalib.data.validators import ImageValidator
            >>> score = 0.8
            >>> validated_score = ImageValidator.validate_pred_score(score)
            >>> validated_score
            tensor(0.8000)
            >>> score_tensor = torch.tensor(0.7)
            >>> validated_score = ImageValidator.validate_pred_score(score_tensor)
            >>> validated_score
            tensor(0.7000)
        """
        if pred_score is None:
            return None

        if not isinstance(pred_score, torch.Tensor):
            try:
                pred_score = torch.tensor(pred_score)
            except Exception as e:
                msg = "Failed to convert pred_score to a torch.Tensor."
                raise ValueError(msg) from e

        return pred_score.to(torch.float32)
Validate the prediction score.

        This method validates and normalizes prediction scores. It handles:
            - Float, numpy array and tensor inputs
            - Type conversion to float32
            - None inputs return None

        Args:
            pred_score (``torch.Tensor`` | ``np.ndarray`` | ``float`` | ``None``):
                Input prediction score.

        Returns:
            ``torch.Tensor`` | ``None``: Validated prediction score as a float32
                tensor, or None.

        Raises:
            TypeError: If ``pred_score`` cannot be converted to a tensor.
            ValueError: If ``pred_score`` is not a scalar.

        Example:
            >>> import torch
            >>> from anomalib.data.validators import ImageValidator
            >>> score = 0.8
            >>> validated_score = ImageValidator.validate_pred_score(score)
            >>> validated_score
            tensor(0.8000)
            >>> score_tensor = torch.tensor(0.7)
            >>> validated_score = ImageValidator.validate_pred_score(score_tensor)
            >>> validated_score
            tensor(0.7000)
        
src/anomalib/data/validators/torch/image.py