human
Complete this python program:
def latest_version(*names, **kwargs):
assistant
#Here is the Python program you requested.

    """Return the latest version of the named package available for upgrade or
    installation
    Currently chooses stable versions, falling back to devel if that does not
    exist.
    CLI Example:
    .. code-block:: bash
    salt \*\ pkg.latest_version <package name>
    salt \*\ pkg.latest_version <package1> <package2> <package3>
    """
    refresh = salt.utils.is_true(kwargs.pop('refresh', True))
    if refresh:
        refresh_db()
    def get_version(pkg_info):
        return (pkg_info['versions']['stable'] or pkg_info['versions']['devel'])
    versions_dict = dict(((key, get_version(val)) for (key, val) in six.iteritems(_info(*names))))
    if (len(names) == 1):
        return next(six.itervalues(versions_dict))
    else:
        return versions_dict