code: def convert_to_attrdict(
      cfg: DictConfig,
      cmdline_args: List[Any] = None,
      dump_config: bool = True,
  ):
      """
      Given the user input Hydra Config, and some command line input options
      to override the config file:
      1. merge and override the command line options in the config
      2. Convert the Hydra OmegaConf to AttrDict structure to make it easy
         to access the keys in the config file
      3. Also check the config version used is compatible and supported in vissl.
         In future, we would want to support upgrading the old config versions if
         we make changes to the VISSL default config structure (deleting, renaming keys)
      4. We infer values of some parameters in the config file using the other
         parameter values.
      """
      if cmdline_args:
          # convert the command line args to DictConfig
          sys.argv = cmdline_args
          cli_conf = OmegaConf.from_cli(cmdline_args)
  
          # merge the command line args with config
          cfg = OmegaConf.merge(cfg, cli_conf)
  
      # Completion of the "defaults.yaml" for the teacher model used for distillation
      # This avoids repeating the same default options in both:
      # - config.MODEL
      # - cfg.config.DISTILLATION.TEACHER_MODEL
      base_model = copy.deepcopy(cfg.config.MODEL)
      with open_dict(base_model):
          base_model.merge_with(cfg.config.DISTILLATION.TEACHER_MODEL)
          cfg.config.DISTILLATION.TEACHER_MODEL = base_model
  
      # convert the config to AttrDict
      cfg = OmegaConf.to_container(cfg)
      cfg = AttrDict(cfg)
  
      # check the cfg has valid version
      check_cfg_version(cfg)
  
      # assert the config and infer
      config = cfg.config
      infer_and_assert_hydra_config(config, cfg.engine_name)
      if dump_config:
          save_attrdict_to_disk(config)
      convert_fsdp_dtypes(config)
      return cfg, config
  
imports: import contextlib
  import copy
  import logging
  import math
  import os
  import pprint
  import re
  import sys
  from typing import Any, List, NamedTuple, Tuple
  import torch
  from hydra.core.override_parser.overrides_parser import OverridesParser
  from omegaconf import DictConfig, OmegaConf, open_dict
  from vissl.config import AttrDict, check_cfg_version
  from vissl.utils.io import save_file
  from vissl.utils.misc import is_augly_available
label_desc: Use image node_id 2 for calling a global function with example usage: convert_to_attrdict(cfg, cmdline_args, dump_config) and returns: cfg,  config