def import_submodules(package, parent_package=None, exclude_submodules=None):
exclude_submodules_dot = [x + '<STR_LIT:.>' for x in exclude_submodules] if exclude_submodules else exclude_submodules<EOL>package = importlib.import_module(package, parent_package)<EOL>for _, name, _ in pkgutil.walk_packages(package.__path__, package.__name__ + '<STR_LIT:.>'):<EOL><INDENT>if exclude_submodules and (name in exclude_submodules or any(name.startswith(x) for x in exclude_submodules_dot)):<EOL><INDENT>continue<EOL><DEDENT>yield importlib.import_module(name)<EOL><DEDENT>
Generator which imports all submodules of a module, recursively, including subpackages

:param package: package name (e.g 'chisel.util'); may be relative if parent_package is provided
:type package: str
:param parent_package: parent package name (e.g 'chisel')
:type package: str
:rtype: iterator of modules