code: def register_module(
      target_symtab, modules, include_types, exclude_names
  ):
      """register subcomponents in modules into target symtable,
      return added components for later clean up"""
      # get a component and return the auto counterpart
  
      # filter the classes in a module
      def filter(module, prefix, check_type, exclude_set):
          filtered = []
          # attrs = vars(module).items()
          # for name, attr in attrs:
          #     if check_type(attr):
          #         m = inspect.getmodule(attr)
          #         if m.__name__.startswith(prefix) and name not in exclude_set:
          #             filtered.append(name)
  
          attrs = dir(module)
          for name in attrs:
              attr = getattr(module, name)
              if not name.startswith("_") and check_type(attr):
                  m = inspect.getmodule(attr)
                  if (
                      m.__name__.startswith(prefix)
                      and name not in exclude_set
                  ):
                      filtered.append(name)
          return filtered
  
      if include_types == COMPONENT_TYPE.CLASS:
  
          def type_checker(x):
              return inspect.isclass(x)
  
          decorator = decorate_cls
      elif include_types == COMPONENT_TYPE.FUNC:
  
          def type_checker(x):
              return inspect.isfunction(x)
  
          decorator = decorate_func
      else:
          invalidInputError(
              False,
              "Unknown Component Type, should be either class or function",
          )
  
      added_components = []
      for m, prefix in modules:
          module = importlib.import_module(m)
          c_names = filter(
              module,
              prefix,
              check_type=type_checker,
              exclude_set=exclude_names,
          )
          # TODO check layers
          for c_name in c_names:
              new_c = decorator(module, c_name)
              if target_symtab.get(c_name, None) is not None:
                  invalidInputError(
                      False,
                      "Fail to register decorated component to the target nano"
                      " module, as it is already defined in the target module."
                      "Use register_module_simple instead.",
                  )
              target_symtab[c_name] = new_c
              added_components.append(c_name)
  
      return added_components
  
file_path: BigDL/python/nano/src/bigdl/nano/automl/utils/register_modules.py
imports: import importlib
  from bigdl.nano.automl.hpo import obj, func
  from bigdl.nano.utils.common import invalidInputError
  import inspect
  from enum import Enum
  import copy
label_desc: Use image node_id 3 for calling a global function with example usage: register_module(target_symtab, modules, include_types, exclude_names) and returns: added_components, filtered, inspect, inspect