code: def load_class_extensions(
      current_module, extension_key, extension_class_validator
  ):
      """Load all registered extensions under the `extension_key` namespace in entry_points.
  
      Attributes:
          current_module: The module itself where extension classes should be added.
          extension_key: The identifier as string for the entry_points to register within the current_module.
          extension_class_validator: A function(class) -> bool, that checks the class for correctness
            before it is registered.
      """
  
      entry_points_result = entry_points()
      if sys.version_info < (3, 10):
          entry_points_group = entry_points_result.get(
              extension_key, []
          )
      else:
          entry_points_group = entry_points_result.select(
              group=extension_key
          )
  
      for entrypoint in entry_points_group:
          _log.debug("processing entrypoint {}".format(extension_key))
          try:
              extension_class_name = entrypoint.name
              extension_class = entrypoint.load()
              _log.debug(
                  "loading entrypoint key {} with name {} with object {}".format(
                      extension_key,
                      extension_class_name,
                      extension_class,
                  )
              )
              _validate_class_name(extension_class_name)
  
              if not extension_class_validator(extension_class):
                  raise ValueError(
                      "class {} failed validation.".format(
                          extension_class
                      )
                  )
  
              if (
                  getattr(current_module, extension_class_name, None)
                  is not None
              ):
                  raise ValueError(
                      "class name {} already exists for module {}.".format(
                          extension_class_name, current_module.__name__
                      )
                  )
  
              setattr(
                  current_module, extension_class_name, extension_class
              )
  
          except Exception as e:  # pragma: no cover
              msg = "Failure while loading {}. Failed to load entrypoint {} with exception {}.".format(
                  extension_key,
                  entrypoint,
                  "".join(
                      traceback.format_exception(
                          type(e), e, e.__traceback__
                      )
                  ),
              )
              _log.warning(msg)
  
              warn(msg)
  
file_path: interpret/python/interpret-core/interpret/ext/extension_utils.py
imports: import sys
  import logging
  from importlib.metadata import entry_points
  import re
  from warnings import warn
  import traceback
label_desc: Use image node_id 2 for calling a global function with example usage: load_class_extensions(current_module, extension_key, extension_class_validator) without return types