code: def instantiate(
      registry, config, *args, partial=False, wrap=None, **kwargs
  ):
      """Instantiate registered module.
  
      registry: Dictionary mapping names to functions or target paths
              (e.g. {'model': 'models.SequenceModel'})
      config: Dictionary with a '_name_' key indicating which element of the registry
              to grab, and kwargs to be passed into the target constructor
      wrap: wrap the target class (e.g. ema optimizer or tasks.wrap)
      *args, **kwargs: additional arguments
              to override the config to pass into the target constructor
      """
      # Case 1: no config
      if config is None:
          return None
      # Case 2a: string means _name_ was overloaded
      if isinstance(config, str):
          _name_ = None
          _target_ = registry[config]
          config = {}
      # Case 2b: grab the desired callable from name
      else:
          _name_ = config.pop("_name_")
          _target_ = registry[_name_]
  
      # Retrieve the right constructor automatically based on type
      if isinstance(_target_, str):
          fn = hydra.utils.get_method(path=_target_)
      elif isinstance(_target_, Callable):
          fn = _target_
      else:
          raise NotImplementedError(
              "instantiate target must be string or callable"
          )
  
      # Instantiate object
      if wrap is not None:
          fn = wrap(fn)
      obj = functools.partial(fn, *args, **config, **kwargs)
  
      # Restore _name_
      if _name_ is not None:
          config["_name_"] = _name_
  
      if partial:
          return obj
      else:
          return obj()
  
file_path: espnet/espnet2/asr/state_spaces/utils.py
imports: import functools
  from typing import Callable, Mapping, Sequence
  import hydra
  from omegaconf import DictConfig, ListConfig
label_desc: Use image node_id 6 for calling a global function with example usage: instantiate(registry, config) and returns: None, obj, obj