code: def get_submodules(module):
      
      if not inspect.ismodule(module):
          raise RuntimeError(
              'Can only extract submodules from a module object, '
              'for example imported via importlib.import_module')
  
      submodules = get_members(module, inspect.ismodule)
  
      module_path = list(getattr(module, '__path__', [None]))[0]
  
      if module_path is not None:
          for item in listdir(module_path):
              module_name = extract_module_name(osp.join(module_path, item))
  
              if module_name is not None:
                  try:
                      submodules[module_name] = importlib.import_module(
                          '.{}'.format(module_name), package=module.__name__)
                  except ImportError:
                      # This is necessary in case random directories are in the path or things can
                      # just not be imported due to other ImportErrors.
                      pass
  
      return submodules
docs: This function imports all sub-modules of the supplied module and returns a dictionary
      with module names as keys and the sub-module objects as values. If the supplied parameter
      is not a module object, a RuntimeError is raised.
  
      :param module: Module object from which to import sub-modules.
      :return: Dict with name-module pairs.