code: def import_submodules(package: Union[str, ModuleType],
                        base_package_for_relative_import: str = None,
                        recursive: bool = True) -> Dict[str, ModuleType]:
      
      # http://stackoverflow.com/questions/3365740/how-to-import-all-submodules
      if isinstance(package, str):
          package = importlib.import_module(package,
                                            base_package_for_relative_import)
      results = {}
      for loader, name, is_pkg in pkgutil.walk_packages(package.__path__):
          full_name = package.__name__ + '.' + name
          log.debug("importing: {}", full_name)
          results[full_name] = importlib.import_module(full_name)
          if recursive and is_pkg:
              results.update(import_submodules(full_name))
      return results
docs: Import all submodules of a module, recursively, including subpackages.
  
      Args:
          package: package (name or actual module)
          base_package_for_relative_import: path to prepend?
          recursive: import submodules too?
  
      Returns:
          dict: mapping from full module name to module