code: def modules_from_dir(path: str) -> Set[str]:
      """List any sys.modules that were imported from a given path."""
      abspath = os.path.abspath(path)
      keys_to_pop = set()
      # sort items before processing, so we always see x before x.y before x.y.z
      for k, v in sorted(sys.modules.items()):
          if v is None:
              # cached miss in sys.modules
              keys_to_pop.add(k)
              continue
  
          if getattr(v, "__file__", None) is None:
              # non-file module, ignore
              continue
  
          # Look for dir containing the module.
          dirname, basename = os.path.split(v.__file__)
          if basename == "__init__.py":
              dirname, basename = os.path.split(dirname)
  
          if dirname == abspath or dirname in keys_to_pop:
              # module was imported from path, or is a submodule of such a module
              keys_to_pop.add(k)
      return keys_to_pop
  
file_path: determined/harness/determined/_import.py
imports: import contextlib
  import os
  import sys
  from importlib import machinery
  from typing import Iterator, Set, no_type_check
label_desc: Use image node_id 1 for calling a global function with example usage: modules_from_dir(path) and returns: keys_to_pop