def import_submodules(package):
if isinstance(package, str):<EOL><INDENT>package = importlib.import_module(package)<EOL><DEDENT>results = {}<EOL>for _, full_name, is_pkg in pkgutil.walk_packages(package.__path__, package.__name__ + '<STR_LIT:.>'):<EOL><INDENT>results[full_name] = importlib.import_module(full_name)<EOL>if is_pkg:<EOL><INDENT>results.update(import_submodules(full_name))<EOL><DEDENT><DEDENT>return results<EOL>
Return list of imported module instances from beneath root_package