def _handle_invalid_range(msg: Optional[str], raises: bool, min_val: float | Tensor, max_val: float | Tensor) -> bool:
    """Helper function to handle invalid range cases."""
    err_msg = f"Invalid image value range. Expect [0, 1] but got [{min_val}, {max_val}]."
    if msg is not None:
        err_msg += f"\n{msg}"
    if raises:
        raise ValueError(err_msg)
    return False
Helper function to handle invalid range cases.
kornia/core/check.py