code: def import_module_and_submodules(
      package_name: str, exclude: Optional[Set[str]] = None
  ) -> None:
      """
      Import all public submodules under the given package.
      Primarily useful so that people using AllenNLP as a library
      can specify their own custom packages and have their custom
      classes get loaded and registered.
      """
      # take care of None
      exclude = exclude if exclude else set()
      try:
          import checklist  # noqa
      except ImportError:
          # exclude modules that depends on checklist being present
          exclude |= {"allennlp.confidence_checks.task_checklists"}
  
      if package_name in exclude:
          return
  
      importlib.invalidate_caches()
  
      # For some reason, python doesn't always add this by default to your path, but you pretty much
      # always want it when using `--include-package`.  And if it's already there, adding it again at
      # the end won't hurt anything.
      with push_python_path("."):
          # Import at top level
          module = importlib.import_module(package_name)
          path = getattr(module, "__path__", [])
          path_string = "" if not path else path[0]
  
          # walk_packages only finds immediate children, so need to recurse.
          for module_finder, name, _ in pkgutil.walk_packages(path):
              # Sometimes when you import third-party libraries that are on your path,
              # `pkgutil.walk_packages` returns those too, so we need to skip them.
              if path_string and module_finder.path != path_string:  # type: ignore[union-attr]
                  continue
              if name.startswith("_"):
                  # skip directly importing private subpackages
                  continue
              if name.startswith("test"):
                  # as long as allennlp.common.testing is not under tests/, exclude it
                  continue
              subpackage = f"{package_name}.{name}"
              import_module_and_submodules(subpackage, exclude=exclude)
  
imports: import hashlib
  import io
  from datetime import timedelta
  import importlib
  import json
  import logging
  import os
  import pkgutil
  import random
  import sys
  import signal
  from contextlib import contextmanager
  from itertools import islice, zip_longest
  from pathlib import Path
  from typing import Any, Callable, Dict, Generator, Iterable, Iterator, List, Optional, Tuple, TypeVar, Union, Sequence, Set
  import dill
  import numpy
  import spacy
  import torch
  import torch.distributed
  from spacy.cli.download import download
  from spacy.language import Language
  import base58
  from allennlp.common.checks import log_pytorch_version_info
  from allennlp.common.params import Params
label_desc: Use image node_id 11 for calling a global function with example usage: import_module_and_submodules(package_name, exclude) without return types