code: def instantiate(config: Any, *args: Any, **kwargs: Any) -> Any:
      """
      :param config: An config object describing what to call and what params to use.
                     In addition to the parameters, the config must contain:
                     _target_ : target class or callable name (str)
                     And may contain:
                     _args_: List-like of positional arguments to pass to the target
                     _recursive_: Construct nested objects as well (bool).
                                  True by default.
                                  may be overridden via a _recursive_ key in
                                  the kwargs
                     _convert_: Conversion strategy
                          none    : Passed objects are DictConfig and ListConfig, default
                          partial : Passed objects are converted to dict and list, with
                                    the exception of Structured Configs (and their fields).
                          object  : Passed objects are converted to dict and list.
                                    Structured Configs are converted to instances of the
                                    backing dataclass / attr class.
                          all     : Passed objects are dicts, lists and primitives without
                                    a trace of OmegaConf containers. Structured configs
                                    are converted to dicts / lists too.
                     _partial_: If True, return functools.partial wrapped method or object
                                False by default. Configure per target.
      :param args: Optional positional parameters pass-through
      :param kwargs: Optional named parameters to override
                     parameters in the config object. Parameters not present
                     in the config objects are being passed as is to the target.
                     IMPORTANT: dataclasses instances in kwargs are interpreted as config
                                and cannot be used as passthrough
      :return: if _target_ is a class name: the instantiated object
               if _target_ is a callable: the return value of the call
      """
  
      # Return None if config is None
      if config is None:
          return None
  
      # TargetConf edge case
      if isinstance(config, TargetConf) and config._target_ == "???":
          # Specific check to give a good warning about failure to annotate _target_ as a string.
          raise InstantiationException(
              dedent(
                  f"""\
                  Config has missing value for key `_target_`, cannot instantiate.
                  Config type: {type(config).__name__}
                  Check that the `_target_` key in your dataclass is properly annotated and overridden.
                  A common problem is forgetting to annotate _target_ as a string : '_target_: str = ...'"""
              )
          )
          # TODO: print full key
  
      if isinstance(config, (dict, list)):
          config = _prepare_input_dict_or_list(config)
  
      kwargs = _prepare_input_dict_or_list(kwargs)
  
      # Structured Config always converted first to OmegaConf
      if is_structured_config(config) or isinstance(
          config, (dict, list)
      ):
          config = OmegaConf.structured(
              config, flags={"allow_objects": True}
          )
  
      if OmegaConf.is_dict(config):
          # Finalize config (convert targets to strings, merge with kwargs)
          config_copy = copy.deepcopy(config)
          config_copy._set_flag(
              flags=["allow_objects", "struct", "readonly"],
              values=[True, False, False],
          )
          config_copy._set_parent(config._get_parent())
          config = config_copy
  
          if kwargs:
              config = OmegaConf.merge(config, kwargs)
  
          OmegaConf.resolve(config)
  
          _recursive_ = config.pop(_Keys.RECURSIVE, True)
          _convert_ = config.pop(_Keys.CONVERT, ConvertMode.NONE)
          _partial_ = config.pop(_Keys.PARTIAL, False)
  
          return instantiate_node(
              config,
              *args,
              recursive=_recursive_,
              convert=_convert_,
              partial=_partial_,
          )
      elif OmegaConf.is_list(config):
          # Finalize config (convert targets to strings, merge with kwargs)
          config_copy = copy.deepcopy(config)
          config_copy._set_flag(
              flags=["allow_objects", "struct", "readonly"],
              values=[True, False, False],
          )
          config_copy._set_parent(config._get_parent())
          config = config_copy
  
          OmegaConf.resolve(config)
  
          _recursive_ = kwargs.pop(_Keys.RECURSIVE, True)
          _convert_ = kwargs.pop(_Keys.CONVERT, ConvertMode.NONE)
          _partial_ = kwargs.pop(_Keys.PARTIAL, False)
  
          if _partial_:
              raise InstantiationException(
                  "The _partial_ keyword is not compatible with top-level list instantiation"
              )
  
          return instantiate_node(
              config,
              *args,
              recursive=_recursive_,
              convert=_convert_,
              partial=_partial_,
          )
      else:
          raise InstantiationException(
              dedent(
                  f"""\
                  Cannot instantiate config of type {type(config).__name__}.
                  Top level config must be an OmegaConf DictConfig/ListConfig object,
                  a plain dict/list, or a Structured Config class or instance."""
              )
          )
  
imports: import copy
  import functools
  from enum import Enum
  from textwrap import dedent
  from typing import Any, Callable, Dict, List, Sequence, Tuple, Union
  from omegaconf import OmegaConf, SCMode
  from omegaconf._utils import is_structured_config
  from hydra._internal.utils import _locate
  from hydra.errors import InstantiationException
  from hydra.types import ConvertMode, TargetConf
label_desc: Use image node_id 7 for calling a global function with example usage: instantiate(config) and returns: None, instantiate_node, instantiate_node