<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def lookup_jid(jid,
               ext_source=None,
               returned=True,
               missing=False,
               display_progress=False):
    '''
    Return the printout from a previously executed job

    jid
        The jid to look up.

    ext_source
        The external job cache to use. Default: `None`.

    returned : True
        If ``True``, include the minions that did return from the command.

        .. versionadded:: 2015.8.0

    missing : False
        If ``True``, include the minions that did *not* return from the
        command.

    display_progress : False
        If ``True``, fire progress events.

        .. versionadded:: 2015.5.0

    CLI Example:

    .. code-block:: bash

        salt-run jobs.lookup_jid 20130916125524463507
        salt-run jobs.lookup_jid 20130916125524463507 --out=highstate
    '''
    ret = {}
    mminion = salt.minion.MasterMinion(__opts__)
    returner = _get_returner((
        __opts__['ext_job_cache'],
        ext_source,
        __opts__['master_job_cache']
    ))

    try:
        data = list_job(
            jid,
            ext_source=ext_source,
            display_progress=display_progress
        )
    except TypeError:
        return ('Requested returner could not be loaded. '
                'No JIDs could be retrieved.')

    targeted_minions = data.get('Minions', [])
    returns = data.get('Result', {})

    if returns:
        for minion in returns:
            if display_progress:
                __jid_event__.fire_event({'message': minion}, 'progress')
            if u'return' in returns[minion]:
                if returned:
                    ret[minion] = returns[minion].get(u'return')
            else:
                if returned:
                    ret[minion] = returns[minion].get('return')
    if missing:
        for minion_id in (x for x in targeted_minions if x not in returns):
            ret[minion_id] = 'Minion did not return'

    # We need to check to see if the 'out' key is present and use it to specify
    # the correct outputter, so we get highstate output for highstate runs.
    try:
        # Check if the return data has an 'out' key. We'll use that as the
        # outputter in the absence of one being passed on the CLI.
        outputter = None
        _ret = returns[next(iter(returns))]
        if 'out' in _ret:
            outputter = _ret['out']
        elif 'outputter' in _ret.get('return', {}).get('return', {}):
            outputter = _ret['return']['return']['outputter']
    except (StopIteration, AttributeError):
        pass

    if outputter:
        return {'outputter': outputter, 'data': ret}
    else:
        return ret