code: def create(cls_or_name, **kwargs):
      """
      Create an instance of given module class.
  
      Args:
          cls_or_name (type or str): Class of which to create instance.
  
      Returns: instance of type `cls_or_name`
      """
      assert type(cls_or_name) in [
          type,
          str,
      ], "should be a class or name of a class"
      name = (
          type(cls_or_name) == str
          and cls_or_name
          or cls_or_name.__name__
      )
      if name in global_config:
          if isinstance(global_config[name], SchemaDict):
              pass
          elif hasattr(global_config[name], "__dict__"):
              # support instance return directly
              return global_config[name]
          else:
              raise ValueError(
                  "The module {} is not registered".format(name)
              )
      else:
          raise ValueError(
              "The module {} is not registered".format(name)
          )
  
      config = global_config[name]
      cls = getattr(config.pymodule, name)
      cls_kwargs = {}
      cls_kwargs.update(global_config[name])
  
      # parse `shared` annoation of registered modules
      if getattr(config, "shared", None):
          for k in config.shared:
              target_key = config[k]
              shared_conf = config.schema[k].default
              assert isinstance(shared_conf, SharedConfig)
              if target_key is not None and not isinstance(
                  target_key, SharedConfig
              ):
                  continue  # value is given for the module
              elif shared_conf.key in global_config:
                  # `key` is present in config
                  cls_kwargs[k] = global_config[shared_conf.key]
              else:
                  cls_kwargs[k] = shared_conf.default_value
  
      # parse `inject` annoation of registered modules
      if getattr(cls, "from_config", None):
          cls_kwargs.update(cls.from_config(config, **kwargs))
  
      if getattr(config, "inject", None):
          for k in config.inject:
              target_key = config[k]
              # optional dependency
              if target_key is None:
                  continue
  
              if isinstance(target_key, dict) or hasattr(
                  target_key, "__dict__"
              ):
                  if "name" not in target_key.keys():
                      continue
                  inject_name = str(target_key["name"])
                  if inject_name not in global_config:
                      raise ValueError(
                          "Missing injection name {} and check it's name in cfg file".format(
                              k
                          )
                      )
                  target = global_config[inject_name]
                  for i, v in target_key.items():
                      if i == "name":
                          continue
                      target[i] = v
                  if isinstance(target, SchemaDict):
                      cls_kwargs[k] = create(inject_name)
              elif isinstance(target_key, str):
                  if target_key not in global_config:
                      raise ValueError(
                          "Missing injection config:", target_key
                      )
                  target = global_config[target_key]
                  if isinstance(target, SchemaDict):
                      cls_kwargs[k] = create(target_key)
                  elif hasattr(target, "__dict__"):  # serialized object
                      cls_kwargs[k] = target
              else:
                  raise ValueError(
                      "Unsupported injection type:", target_key
                  )
      # prevent modification of global config values of reference types
      # (e.g., list, dict) from within the created module instances
      # kwargs = copy.deepcopy(kwargs)
      return cls(**cls_kwargs)
  
imports: from __future__ import absolute_import
  from __future__ import print_function
  from __future__ import division
  import importlib
  import os
  import sys
  import yaml
  import collections
  from .config.schema import SchemaDict, SharedConfig, extract_schema
  from .config.yaml_helpers import serializable
label_desc: Use image node_id 9 for calling a global function with example usage: create(cls_or_name) and returns: cls, global_config