code: def _add_subconfig_keys(
      model_cfg: "DictConfig",
      update_cfg: "DictConfig",
      subconfig_key: str,
  ):
      """
      For certain sub-configs, the default values specified by the NemoConfig class is insufficient.
      In order to support every potential value in the merge between the `update_cfg`, it would require
      explicit definition of all possible cases.
  
      An example of such a case is Optimizers, and their equivalent Schedulers. All optimizers share a few basic
      details - such as name and lr, but almost all require additional parameters - such as weight decay.
      It is impractical to create a config for every single optimizer + every single scheduler combination.
  
      In such a case, we perform a dual merge. The Optim and Sched Dataclass contain the bare minimum essential
      components. The extra values are provided via update_cfg.
  
      In order to enable the merge, we first need to update the update sub-config to incorporate the keys,
      with dummy temporary values (merge update config with model config). This is done on a copy of the
      update sub-config, as the actual override values might be overriden by the NemoConfig defaults.
  
      Then we perform a merge of this temporary sub-config with the actual override config in a later step
      (merge model_cfg with original update_cfg, done outside this function).
  
      Args:
          model_cfg: A DictConfig instantiated from the NemoConfig subclass.
          update_cfg: A DictConfig that mirrors the structure of `model_cfg`, used to update its default values.
          subconfig_key: A str key used to check and update the sub-config.
  
      Returns:
          A ModelPT DictConfig with additional keys added to the sub-config.
      """
      if not _HAS_HYDRA:
          logging.error(
              "This function requires Hydra/Omegaconf and it was not installed."
          )
          exit(1)
      with open_dict(model_cfg.model):
          # Create copy of original model sub config
          if subconfig_key in update_cfg.model:
              if subconfig_key not in model_cfg.model:
                  # create the key as a placeholder
                  model_cfg.model[subconfig_key] = None
  
              subconfig = copy.deepcopy(model_cfg.model[subconfig_key])
              update_subconfig = copy.deepcopy(
                  update_cfg.model[subconfig_key]
              )
  
              # Add the keys and update temporary values, will be updated during full merge
              subconfig = OmegaConf.merge(update_subconfig, subconfig)
              # Update sub config
              model_cfg.model[subconfig_key] = subconfig
  
      return model_cfg
  
file_path: NeMo/nemo/utils/config_utils.py
imports: import copy
  import inspect
  from dataclasses import is_dataclass
  from typing import Dict, List, Optional
  from nemo.utils import logging
label_desc: Use image node_id 3 for calling a global function with example usage: _add_subconfig_keys(model_cfg, update_cfg, subconfig_key) and returns: model_cfg