code: def _import_submodules_recursively(obj, mod_path):
      # Since modules can freely import any other modules, immediately mark this
      # obj as visited so submodules that import it are not re-examined
      # infinitely.
      _visited.add(obj)
      for name in dir(obj):
          sub_obj = getattr(obj, name)
  
          if type(sub_obj) is ModuleType:
              sub_mod_path = f"{mod_path}.{name}"
              # Do not overwrite modules that are already present, such as those
              # intended to override which were imported separately above.
              if sub_mod_path not in sys.modules:
                  sys.modules[sub_mod_path] = sub_obj
              if sub_obj not in _visited:
                  _import_submodules_recursively(sub_obj, sub_mod_path)
  
file_path: cugraph/python/cugraph/cugraph/experimental/compat/nx/__init__.py
imports: import importlib
  from types import ModuleType
  import sys
  from networkx import *
  from cugraph.experimental.compat.nx import algorithms
  from cugraph.experimental.compat.nx.algorithms import *
  from cugraph.experimental.compat.nx.algorithms import link_analysis
  from cugraph.experimental.compat.nx.algorithms.link_analysis import *
label_desc: Use image node_id 1 for calling a global function with example usage: _import_submodules_recursively(obj, mod_path) without return types