'Given a dict from a client, create a new event.
Creates an FrozenEvent object, filling out auth_events, prev_events,
etc.
Adds display names to Join membership events.
Args:
requester
event_dict (dict): An entire event
token_id (str)
txn_id (str)
prev_event_ids (list): The prev event ids to use when creating the event
Returns:
Tuple of created event (FrozenEvent), Context'

@defer.inlineCallbacks
def create_event(self, requester, event_dict, token_id=None, txn_id=None, prev_event_ids=None):

    builder = self.event_builder_factory.new(event_dict)
    with (yield self.limiter.queue(builder.room_id)):
        self.validator.validate_new(builder)
        if (builder.type == EventTypes.Member):
            membership = builder.content.get('membership', None)
            target = UserID.from_string(builder.state_key)
            if (membership in {Membership.JOIN, Membership.INVITE}):
                profile = self.hs.get_handlers().profile_handler
                content = builder.content
                try:
                    if ('displayname' not in content):
                        content['displayname'] = (yield profile.get_displayname(target))
                    if ('avatar_url' not in content):
                        content['avatar_url'] = (yield profile.get_avatar_url(target))
                except Exception as e:
                    logger.info('Failed    to    get    profile    information    for    %r:    %s', target, e)
        if (token_id is not None):
            builder.internal_metadata.token_id = token_id
        if (txn_id is not None):
            builder.internal_metadata.txn_id = txn_id
        (event, context) = (yield self._create_new_client_event(builder=builder, requester=requester, prev_event_ids=prev_event_ids))
    defer.returnValue((event, context))
