code: def is_local_source(filename, modname, experiment_path):
      """Check if a module comes from the given experiment path.
  
      Check if a module, given by name and filename, is from (a subdirectory of )
      the given experiment path.
      This is used to determine if the module is a local source file, or rather
      a package dependency.
  
      Parameters
      ----------
      filename: str
          The absolute filename of the module in question.
          (Usually module.__file__)
      modname: str
          The full name of the module including parent namespaces.
      experiment_path: str
          The base path of the experiment.
  
      Returns
      -------
      bool:
          True if the module was imported locally from (a subdir of) the
          experiment_path, and False otherwise.
      """
      filename = Path(os.path.abspath(os.path.realpath(filename)))
      experiment_path = Path(
          os.path.abspath(os.path.realpath(experiment_path))
      )
      if experiment_path not in filename.parents:
          return False
      rel_path = filename.relative_to(experiment_path)
      path_parts = convert_path_to_module_parts(rel_path)
  
      mod_parts = modname.split(".")
      if path_parts == mod_parts:
          return True
      if len(path_parts) > len(mod_parts):
          return False
      abs_path_parts = convert_path_to_module_parts(filename)
      return all(
          [
              p == m
              for p, m in zip(
                  reversed(abs_path_parts), reversed(mod_parts)
              )
          ]
      )
  
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 5 for calling a global function with example usage: is_local_source(filename, modname, experiment_path) and returns: all, False, True, False