def validate_float_arg(value, name):
    """check penalty number availability, raise ValueError if failed."""
    if (
        not isinstance(value, (float, int))
        or (math.isinf(value) or math.isnan(value))
        or value < 0
    ):
        raise ValueError(
            f"Invalid value for argument {name}: expected a non-negative float."
            f"Received: {name}={value}"
        )
    return float(value)
check penalty number availability, raise ValueError if failed.
keras/src/regularizers/regularizers.py