code: def create(cls, mod):
      if not cls.modname_to_dist:
          # some packagenames don't match the module names (e.g. PyYAML)
          # so we set up a dict to map from module name to package name
          for dist in pkg_resources.working_set:
              try:
                  toplevel_names = dist._get_metadata("top_level.txt")
                  for tln in toplevel_names:
                      cls.modname_to_dist[tln] = (
                          dist.project_name,
                          dist.version,
                      )
              except Exception:
                  pass
  
      name, version = cls.modname_to_dist.get(
          mod.__name__, (mod.__name__, None)
      )
  
      return PackageDependency(name, version)
  
imports: import functools
  import hashlib
  import os.path
  import re
  import sys
  from pathlib import Path
  import pkg_resources
  import sacred.optional
  from sacred import SETTINGS
  from sacred.utils import iter_prefixes
label_desc: Use image node_id 8 for calling the PackageDependency obj's underlying member method code with example usage: obj.create(cls, mod) and returns: PackageDependency