code: def get_imported_packages() -> Dict[str, str]:
      """
      Returns a list of packages that have been imported, as a {name: version} dict.
      """
      try:
          # Should we vendor pkg_resources? See https://github.com/replicate/keepsake/issues/350
          import pkg_resources
      except ImportError:
          console.warn(
              "Could not import setuptools/pkg_resources, not tracking package versions"
          )
          return {}
      result = {}
      for d in pkg_resources.working_set:
          if is_imported(d.key):
              result[d.key] = d.version
      return result
  
imports: from typing import Dict
  import sys
  from .None import console
label_desc: Use image node_id 1 for calling a global function with example usage: get_imported_packages() and returns: result, dict