'Given a list of event_ids and type tuples, return a list of state
dicts for each event. The state dicts will only have the type/state_keys
that are in the `types` list.
Args:
event_ids (list)
types (list): List of (type, state_key) tuples which are used to
filter the state fetched. `state_key` may be None, which matches
any `state_key`
Returns:
deferred: A list of dicts corresponding to the event_ids given.
The dicts are mappings from (type, state_key) -> state_events'

@defer.inlineCallbacks
def get_state_for_events(self, event_ids, types):

    event_to_groups = (yield self._get_state_group_for_events(event_ids))
    groups = set(event_to_groups.itervalues())
    group_to_state = (yield self._get_state_for_groups(groups, types))
    state_event_map = (yield self.get_events([ev_id for sd in group_to_state.itervalues() for ev_id in sd.itervalues()], get_prev_content=False))
    event_to_state = {event_id: {k: state_event_map[v] for (k, v) in group_to_state[group].iteritems() if (v in state_event_map)} for (event_id, group) in event_to_groups.iteritems()}
    defer.returnValue({event: event_to_state[event] for event in event_ids})
