def validate_threshold_bounds(threshold_bounds: tuple[float, float]) -> None:
    """Validate threshold bounds form a valid range.

    Args:
        threshold_bounds: Tuple of (lower, upper) threshold bounds.

    Raises:
        TypeError: If bounds are not floats or not a tuple of length 2.
        ValueError: If upper <= lower.

    Example:
        >>> validate_threshold_bounds((0.1, 0.9))  # No error
        >>> validate_threshold_bounds((0.9, 0.1))  # Raises ValueError
        ValueError: Expected the upper bound to be greater than the lower bound
    """
    if not isinstance(threshold_bounds, tuple):
        msg = f"Expected threshold bounds to be a tuple, but got {type(threshold_bounds)}."
        raise TypeError(msg)

    if len(threshold_bounds) != 2:
        msg = f"Expected threshold bounds to be a tuple of length 2, but got {len(threshold_bounds)}."
        raise ValueError(msg)

    lower, upper = threshold_bounds

    if not isinstance(lower, float):
        msg = f"Expected lower threshold bound to be a float, but got {type(lower)}."
        raise TypeError(msg)

    if not isinstance(upper, float):
        msg = f"Expected upper threshold bound to be a float, but got {type(upper)}."
        raise TypeError(msg)

    if upper <= lower:
        msg = f"Expected the upper bound to be greater than the lower bound, but got {upper} <= {lower}."
        raise ValueError(msg)
Validate threshold bounds form a valid range.

    Args:
        threshold_bounds: Tuple of (lower, upper) threshold bounds.

    Raises:
        TypeError: If bounds are not floats or not a tuple of length 2.
        ValueError: If upper <= lower.

    Example:
        >>> validate_threshold_bounds((0.1, 0.9))  # No error
        >>> validate_threshold_bounds((0.9, 0.1))  # Raises ValueError
        ValueError: Expected the upper bound to be greater than the lower bound
    
src/anomalib/metrics/pimo/_validate.py