code: def build_from_registry(config, registry: Registry):
      r"""Returns an object constructed from `config`, the type of the object
      is specified by `registry`.
  
      Note:
          the `config` is used to construct the return object such as `LAYERS`, `OPTIMIZERS`
          and other support types in `registry`. The `config` should contain
          all required parameters of corresponding object. The details of support
          types in `registry` and the `mod_type` in `config` could be found in
          `registry <https://github.com/hpcaitech/ColossalAI/blob/main/colossalai/registry/__init__.py>`_.
  
      Args:
          config (dict or :class:`colossalai.context.colossalai.context.Config`): information
              used in the construction of the return object.
          registry (:class:`Registry`): A registry specifying the type of the return object
  
      Returns:
          A Python object specified by `registry`.
  
      Raises:
          Exception: Raises an Exception if an error occurred when building from registry.
      """
      config_ = config.copy()  # keep the original config untouched
      assert isinstance(
          registry, Registry
      ), f"Expected type Registry but got {type(registry)}"
  
      mod_type = config_.pop("type")
      assert registry.has(
          mod_type
      ), f"{mod_type} is not found in registry {registry.name}"
      try:
          obj = registry.get_module(mod_type)(**config_)
      except Exception as e:
          print(
              f"An error occurred when building {mod_type} from registry {registry.name}",
              flush=True,
          )
          raise e
  
      return obj
  
imports: import inspect
  from colossalai.legacy.registry import *
label_desc: Use image node_id 2 for calling a global function with example usage: build_from_registry(config, registry) and returns: obj