code: def fetch_config_from_cmdargs(cmdargs):
      """Turn flat cmdargs into nested dicts like orion.core.config."""
      config_file = cmdargs.pop("config", None)
      tmp_cmdargs = copy.deepcopy(cmdargs)
      tmp_cmdargs["config"] = config_file
      cmdargs["config"] = config_file
      cmdargs = tmp_cmdargs
  
      cmdargs_config = {}
  
      if cmdargs.get("max_trials") is not None:
          log.warning(
              "--max-trials is deprecated and will be removed in v0.3. "
              "Use --exp-max-trials instead"
          )
          cmdargs_config["experiment.max_trials"] = cmdargs.pop(
              "max_trials"
          )
  
      if cmdargs.get("worker_trials") is not None:
          log.warning(
              "--worker-trials is deprecated and will be removed in v0.3. "
              "Use --worker-max-trials instead"
          )
          cmdargs_config["worker.max_trials"] = cmdargs.pop(
              "worker_trials"
          )
  
      mappings = dict(
          experiment=dict(
              max_broken="exp_max_broken", max_trials="exp_max_trials"
          ),
          worker=dict(
              max_broken="worker_max_broken",
              max_trials="worker_max_trials",
          ),
          evc=dict(enable="enable_evc"),
      )
  
      global_config = orion.core.config.to_dict()
  
      for key in ["config", "user_args"]:
          if cmdargs.get(key) not in [False, None]:
              cmdargs_config[key] = cmdargs[key]
  
      for key in ["name", "user", "version"]:
          if cmdargs.get(key) not in [False, None]:
              cmdargs_config[f"experiment.{key}"] = cmdargs[key]
  
      for key in ["branch_from", "branch_to"]:
          if cmdargs.get(key) not in [False, None]:
              cmdargs_config[f"evc.{key}"] = cmdargs[key]
  
      # Apply config at the root
      for key in ["debug"]:
          # Adapt to cli arguments
          cli_key = mappings.get(key, key)
  
          value = cmdargs.pop(cli_key, None)
          if value is not None:
              cmdargs_config[f"{key}"] = value
  
      # Apply to subconfigs
      for key in ["experiment", "worker", "evc"]:
          for subkey in global_config[key].keys():
              # Adapt to cli arguments
              cli_key = mappings.get(key, {}).get(subkey, subkey)
  
              value = cmdargs.pop(cli_key, None)
              if value is not None:
                  cmdargs_config[f"{key}.{subkey}"] = value
  
      return unflatten(cmdargs_config)
  
imports: import copy
  import getpass
  import hashlib
  import logging
  import os
  import git
  import yaml
  from numpy import inf
  import orion
  import orion.core
  from orion.core.io.orion_cmdline_parser import OrionCmdlineParser
  from orion.core.utils.flatten import unflatten
label_desc: Use image node_id 3 for calling a global function with example usage: fetch_config_from_cmdargs(cmdargs) and returns: unflatten