code: def get_installed_pkgs_detail():
      """
      HACK: bugfix of the original pigar get_installed_pkgs_detail
  
      Get mapping for import top level name
      and install package name with version.
      """
      mapping = dict()
  
      for path in sys.path:
          if os.path.isdir(path) and path.rstrip("/").endswith(
              ("site-packages", "dist-packages")
          ):
              new_mapping = _search_path(path)
              # BUGFIX:
              # override with previous, just like python resolves imports, the first match is the one used.
              # unlike the original implementation, where the last one is used.
              new_mapping.update(mapping)
              mapping = new_mapping
  
      # HACK: prefer tensorflow_gpu over tensorflow
      if "tensorflow_gpu" in mapping:
          mapping["tensorflow"] = mapping["tensorflow_gpu"]
  
      # HACK: prefer tensorflow_macos over tensorflow
      if "tensorflow_macos" in mapping:
          p = mapping.pop("tensorflow_macos", None)
          if p and isinstance(p, (tuple, list)) and len(p) == 2:
              mapping["tensorflow"] = ("tensorflow", p[1])
  
      return mapping
  
imports: from __future__ import print_function, division, absolute_import
  import json
  import os
  import sys
  import six
  import fnmatch
  import importlib
  import ast
  import doctest
  import collections
  import functools
  from pathlib2 import Path
  from .utils import parse_git_config
  from .modules import ImportedModules
label_desc: Use image node_id 5 for calling a global function with example usage: get_installed_pkgs_detail() and returns: mapping