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

def list_upgrades(refresh=True, **kwargs):
    '''
    List those packages for which an upgrade is available

    The ``fromrepo`` argument is also supported, as used in pkg states.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_upgrades

    jail
        List upgrades within the specified jail

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.list_upgrades jail=<jail name or id>

    chroot
        List upgrades within the specified chroot (ignored if ``jail`` is
        specified)

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.list_upgrades chroot=/path/to/chroot

    root
        List upgrades within the specified root (ignored if ``jail`` is
        specified)

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.list_upgrades root=/path/to/chroot

    '''
    jail = kwargs.pop('jail', None)
    chroot = kwargs.pop('chroot', None)
    root = kwargs.pop('root', None)
    fromrepo = kwargs.pop('fromrepo', None)

    cmd = _pkg(jail, chroot, root)
    cmd.extend(['upgrade', '--dry-run', '--quiet'])

    if not refresh:
        cmd.append('--no-repo-update')
    if fromrepo:
        cmd.extend(['--repository', fromrepo])

    out = __salt__['cmd.run_stdout'](cmd, output_loglevel='trace', python_shell=False, ignore_retcode=True)

    return {pkgname: pkgstat['version']['new'] for pkgname, pkgstat
            in six.iteritems(_parse_upgrade(out)['upgrade'])}