<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_versions(requirements=True, key=None):
 """ Get the version information for psyplot, the plugins and its requirements Parameters requirements: bool If True, the requirements of the plugins and psyplot are investigated key: func A function that determines whether a plugin shall be considererd or not. The function must take a single argument, that is the name of the plugin as string, and must return True (import the plugin) or False (skip the plugin). If None, all plugins are imported Returns ------- dict A mapping from ``'psyplot'``/the plugin names to a dictionary with the ``'version'`` key and the corresponding version is returned. If `requirements` is True, it also contains a mapping from ``'requirements'`` a dictionary with the versions Examples -------- Using the built-in JSON module, we get something like .. code-block:: python import json print(json.dumps(psyplot.get_versions(), indent=4)) { "psy_simple.plugin": { "version": "1.0.0.dev0" }, "psyplot": { "version": "1.0.0.dev0", "requirements": { "matplotlib": "1.5.3", "numpy": "1.11.3", "pandas": "0.19.2", "xarray": "0.9.1" } }, "psy_maps.plugin": { "version": "1.0.0.dev0", "requirements": { "cartopy": "0.15.0" } } } """

    from pkg_resources import iter_entry_points
    ret = {'psyplot': _get_versions(requirements)}
    for ep in iter_entry_points(group='psyplot', name='plugin'):
        if str(ep) in rcParams._plugins:
            logger.debug('Loading entrypoint %s', ep)
            if key is not None and not key(ep.module_name):
                continue
            mod = ep.load()
            try:
                ret[str(ep.module_name)] = mod.get_versions(requirements)
            except AttributeError:
                ret[str(ep.module_name)] = {
                    'version': getattr(mod, 'plugin_version',
                                       getattr(mod, '__version__', ''))}
    if key is None:
        try:
            import psyplot_gui
        except ImportError:
            pass
        else:
            ret['psyplot_gui'] = psyplot_gui.get_versions(requirements)
    return ret