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

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

        Args:
            pred_label (``torch.Tensor`` | ``np.ndarray`` | ``float`` | ``None``):
                Input prediction label.

        Returns:
            ``torch.Tensor`` | ``None``: Validated prediction label as a boolean
                tensor, or None.

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

        Example:
            >>> import torch
            >>> from anomalib.data.validators import ImageValidator
            >>> label = torch.tensor(1)
            >>> validated_label = ImageValidator.validate_pred_label(label)
            >>> validated_label
            tensor(True)
        """
        if pred_label is None:
            return None
        if not isinstance(pred_label, torch.Tensor):
            try:
                pred_label = torch.tensor(pred_label)
            except Exception as e:
                msg = "Failed to convert pred_score to a torch.Tensor."
                raise ValueError(msg) from e
        pred_label = pred_label.squeeze()
        if pred_label.ndim != 0:
            msg = f"Predicted label must be a scalar, got shape {pred_label.shape}."
            raise ValueError(msg)
        return pred_label.to(torch.bool)
Validate the prediction label.

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

        Args:
            pred_label (``torch.Tensor`` | ``np.ndarray`` | ``float`` | ``None``):
                Input prediction label.

        Returns:
            ``torch.Tensor`` | ``None``: Validated prediction label as a boolean
                tensor, or None.

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

        Example:
            >>> import torch
            >>> from anomalib.data.validators import ImageValidator
            >>> label = torch.tensor(1)
            >>> validated_label = ImageValidator.validate_pred_label(label)
            >>> validated_label
            tensor(True)
        
src/anomalib/data/validators/torch/image.py