def filter_instances(instances, filter_dict):
    """Takes a list of instances and returns the subset of that list that meets the filter_dict's criteria."""
    filter_function = lambda instance: \
        ("id" not in filter_dict or filter_dict["id"] == instance.id) and \
        ("state" not in filter_dict or filter_dict["state"] == instance.state)
    return filter(filter_function, instances)
dataset/ETHPy150Open bmbouter/Opus/opus/lib/prov/drivers/driver_tools.py/filter_instances/original