code: def import_all(module_or_package):
      
      already_imported = set(sys.modules)
      mod_or_pkg = importlib.import_module(module_or_package)
      if not hasattr(mod_or_pkg, '__path__'):  # is a simple module
          return set(sys.modules) - already_imported
      # else import all modules contained in the package
      [pkg_path] = mod_or_pkg.__path__
      n = len(pkg_path)
      for cwd, dirs, files in os.walk(pkg_path):
          if all(os.path.basename(f) != '__init__.py' for f in files):
              # the current working directory is not a subpackage
              continue
          for f in files:
              if f.endswith('.py'):
                  # convert PKGPATH/subpackage/module.py -> subpackage.module
                  # works at any level of nesting
                  modname = (module_or_package + cwd[n:].replace(os.sep, '.') +
                             '.' + os.path.basename(f[:-3]))
                  importlib.import_module(modname)
      return set(sys.modules) - already_imported
docs: If `module_or_package` is a module, just import it; if it is a package,
      recursively imports all the modules it contains. Returns the names of
      the modules that were imported as a set. The set can be empty if
      the modules were already in sys.modules.