def _make_length_filter_fn(length_name, max_length):
    """Returns a predicate function which takes in data sample
    and returns a bool indicating whether to filter by length.
    """
    def _filter_fn(data):
        return data[length_name] <= max_length
    return _filter_fn