code: def discover_modules(subpackage, package=None):
      if package:
          try:
              _pkg = import_module("." + subpackage, package)
          except ImportError as e:
              raise e
      else:
          _pkg = import_module(subpackage)
  
      pkg_path = _pkg.__path__
      pkg_prefix = _pkg.__name__ + "."
  
      _list = [
          import_module_with_exceptions(modname)
          for importer, modname, ispkg in pkgutil.walk_packages(
              pkg_path, pkg_prefix
          )
      ]
  
      modules_list = [mod for mod in _list if mod is not None]
      return modules_list
  
imports: from importlib import import_module
  import warnings
  import pkgutil
label_desc: Use image node_id 1 for calling a global function with example usage: discover_modules(subpackage, package) and returns: modules_list