code: def get_search_runner_config_from_args(
      args: argparse.Namespace,
  ) -> Dict[str, Any]:
      if args.search_runner_config is not None:
          submitted_search_runner_config = (
              get_dict_from_yaml_or_json_path(args.search_runner_config)
          )
          return submitted_search_runner_config
  
      submitted_exp_config_dict = get_dict_from_yaml_or_json_path(
          args.config_path
      )
      assert (
          "deepspeed_config"
          in submitted_exp_config_dict["hyperparameters"]
      ), (
          "DS AT requires a `hyperparameters.deepspeed_config` key which points "
          "to the deepspeed config json file"
      )
  
      # Also sanity check that if a --deepspeed_config (or in the case of HF
      # --deepspeed) arg is passed in, both configs match. Probably some gotchas here because
      # --deepspeed is also a boolean arg for vanilla deepspeed.
      possible_config_flags = ("--deepspeed", "--deepspeed_config")
  
      submitted_entrypoint: Union[
          List[str], str
      ] = submitted_exp_config_dict["entrypoint"]
      split_entrypoint = get_split_entrypoint(submitted_entrypoint)
  
      for idx in range(len(split_entrypoint) - 1):
          curr_arg, next_arg = split_entrypoint[idx : idx + 2]
          next_arg_is_not_a_flag = next_arg != "-"
          if (
              curr_arg in possible_config_flags
              and next_arg_is_not_a_flag
          ):
              entrypoint_deepspeed_config = next_arg
              hp_deepspeed_config = submitted_exp_config_dict[
                  "hyperparameters"
              ]["deepspeed_config"]
              if entrypoint_deepspeed_config != hp_deepspeed_config:
                  raise ValueError(
                      f"The deepspeed config path in the `hyperparameters` section, "
                      f"{hp_deepspeed_config}, does not match the path in the entrypoint, "
                      f"{entrypoint_deepspeed_config}."
                  )
  
      default_search_runner_config = (
          _defaults.DEFAULT_SEARCH_RUNNER_CONFIG
      )
      if args.max_search_runner_restarts is not None:
          default_search_runner_config[
              "max_restarts"
          ] = args.max_search_runner_restarts
      # Merge with the submitted experiment config so that the search runner shares the project,
      # workspace, etc.
      search_runner_config = merge_dicts(
          submitted_exp_config_dict, default_search_runner_config
      )
      search_runner_config[
          "name"
      ] = f"(DSAT) {search_runner_config['name']}"
      search_runner_config["hyperparameters"] = vars(args)
  
      return search_runner_config
  
imports: import argparse
  import copy
  import json
  import logging
  import pathlib
  import random
  from contextlib import contextmanager
  from typing import Any, Dict, Generator, List, Optional, Union
  import filelock
  import torch
  import determined
  from determined.common import util
  from determined.pytorch.dsat import _defaults
  from determined.util import merge_dicts
label_desc: Use image node_id 5 for calling a global function with example usage: get_search_runner_config_from_args(args) and returns: search_runner_config, submitted_search_runner_config