def is_rate(rate: float | int, zero_ok: bool, one_ok: bool) -> None:
    """Validate a rate parameter.

    Args:
        rate: The rate value to validate.
        zero_ok: Whether 0.0 is an acceptable value.
        one_ok: Whether 1.0 is an acceptable value.

    Raises:
        TypeError: If ``rate`` is not a float or int.
        ValueError: If ``rate`` is outside [0,1] or equals 0/1 when not allowed.

    Example:
        >>> is_rate(0.5, zero_ok=True, one_ok=True)  # No error
        >>> is_rate(0.0, zero_ok=False, one_ok=True)  # Raises ValueError
        ValueError: Rate cannot be 0.
    """
    if not isinstance(rate, float | int):
        msg = f"Expected rate to be a float or int, but got {type(rate)}."
        raise TypeError(msg)

    if rate < 0.0 or rate > 1.0:
        msg = f"Expected rate to be in [0, 1], but got {rate}."
        raise ValueError(msg)

    if not zero_ok and rate == 0.0:
        msg = "Rate cannot be 0."
        raise ValueError(msg)

    if not one_ok and rate == 1.0:
        msg = "Rate cannot be 1."
        raise ValueError(msg)
Validate a rate parameter.

    Args:
        rate: The rate value to validate.
        zero_ok: Whether 0.0 is an acceptable value.
        one_ok: Whether 1.0 is an acceptable value.

    Raises:
        TypeError: If ``rate`` is not a float or int.
        ValueError: If ``rate`` is outside [0,1] or equals 0/1 when not allowed.

    Example:
        >>> is_rate(0.5, zero_ok=True, one_ok=True)  # No error
        >>> is_rate(0.0, zero_ok=False, one_ok=True)  # Raises ValueError
        ValueError: Rate cannot be 0.
    
src/anomalib/metrics/pimo/_validate.py