def variable_is_within_valid_bounds(ds, var_id, minimum, maximum):
    """
    Checks whether variable `var_id` is out of bounds set by arguments
    `minimum` and `maximum`.

    :param ds: netCDF4 Dataset object
    :paran var_id: the variable ID.
    :param minimum: the minimum allowed value (a number)
    :param maximum: the maximum allowed value (a number)
    :return: boolean
    """
    if var_id not in ds.variables: return False

    data = ds.variables[var_id][:]
    mn, mx = data.min(), data.max()

    if mn < minimum or mx > maximum:
        return False

    return True