code: def _update_subconfig(
      model_cfg: "DictConfig",
      update_cfg: "DictConfig",
      subconfig_key: str,
      drop_missing_subconfigs: bool,
  ):
      """
      Updates the NemoConfig DictConfig such that:
      1)  If the sub-config key exists in the `update_cfg`, but does not exist in ModelPT config:
          - Add the sub-config from update_cfg to ModelPT config
  
      2) If the sub-config key does not exist in `update_cfg`, but exists in ModelPT config:
          - Remove the sub-config from the ModelPT config; iff the `drop_missing_subconfigs` flag is set.
  
      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.
          drop_missing_subconfigs: A bool flag, whether to allow deletion of the NemoConfig sub-config,
              if its mirror sub-config does not exist in the `update_cfg`.
  
      Returns:
          The updated DictConfig for the NemoConfig
      """
      if not _HAS_HYDRA:
          logging.error(
              "This function requires Hydra/Omegaconf and it was not installed."
          )
          exit(1)
      with open_dict(model_cfg.model):
          # If update config has the key, but model cfg doesnt have the key
          # Add the update cfg subconfig to the model cfg
          if (
              subconfig_key in update_cfg.model
              and subconfig_key not in model_cfg.model
          ):
              model_cfg.model[subconfig_key] = update_cfg.model[
                  subconfig_key
              ]
  
          # If update config does not the key, but model cfg has the key
          # Remove the model cfg subconfig in order to match layout of update cfg
          if (
              subconfig_key not in update_cfg.model
              and subconfig_key in model_cfg.model
          ):
              if drop_missing_subconfigs:
                  model_cfg.model.pop(subconfig_key)
  
      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 2 for calling a global function with example usage: _update_subconfig(model_cfg, update_cfg, subconfig_key, drop_missing_subconfigs) and returns: model_cfg