def is_rate_range(bounds: tuple[float, float]) -> None:
    """Validate that rate bounds form a valid range.

    Args:
        bounds: Tuple of (lower, upper) rate bounds.

    Raises:
        TypeError: If ``bounds`` is not a tuple of length 2.
        ValueError: If bounds are invalid or lower >= upper.

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

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

    lower, upper = bounds
    is_rate(lower, zero_ok=False, one_ok=False)
    is_rate(upper, zero_ok=False, one_ok=True)

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

    Args:
        bounds: Tuple of (lower, upper) rate bounds.

    Raises:
        TypeError: If ``bounds`` is not a tuple of length 2.
        ValueError: If bounds are invalid or lower >= upper.

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