<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def search_filter(entities, filters):
 """Read all ``entities`` and locally filter them. This method can be used like so:: entities = EntitySearchMixin(entities, {'name': 'foo'}) In this example, only entities where ``entity.name == 'foo'`` holds true are returned. An arbitrary number of field names and values may be provided as filters. .. NOTE:: This method calls :meth:`EntityReadMixin.read`. As a result, this method only works when called on a class that also inherits from :class:`EntityReadMixin`. :param entities: A list of :class:`Entity` objects. All list items should be of the same type. :param filters: A dict in the form ``{field_name: field_value, …}``. :raises nailgun.entity_mixins.NoSuchFieldError: If any of the fields named in ``filters`` do not exist on the entities being filtered. :raises: ``NotImplementedError`` If any of the fields named in ``filters`` are a :class:`nailgun.entity_fields.OneToOneField` or :class:`nailgun.entity_fields.OneToManyField`. """

        # Check to make sure all arguments are sane.
        if len(entities) == 0:
            return entities
        fields = entities[0].get_fields()  # assume all entities are identical
        if not set(filters).issubset(fields):
            raise NoSuchFieldError(
                'Valid filters are {0}, but received {1} instead.'
                .format(fields.keys(), filters.keys())
            )
        for field_name in filters:
            if isinstance(fields[field_name], (OneToOneField, OneToManyField)):
                raise NotImplementedError(
                    'Search results cannot (yet?) be locally filtered by '
                    '`OneToOneField`s and `OneToManyField`s. {0} is a {1}.'
                    .format(field_name, type(fields[field_name]).__name__)
                )

        # The arguments are sane. Filter away!
        filtered = [entity.read() for entity in entities]  # don't alter inputs
        for field_name, field_value in filters.items():
            filtered = [
                entity for entity in filtered
                if getattr(entity, field_name) == field_value
            ]
        return filtered