def _get_entity_pair(entity_id, entities, cache, get_input_peer=get_input_peer
    ):
    """
    Returns ``(entity, input_entity)`` for the given entity ID.
    """
    entity = entities.get(entity_id)
    try:
        input_entity = cache[entity_id]
    except KeyError:
        try:
            input_entity = get_input_peer(entity)
        except TypeError:
            input_entity = None
    return entity, input_entity
