code: def get_ds_config_from_hparams(
      hparams: Dict[str, Any],
      base_dir: Union[pathlib.Path, str] = CURR_DIR,
  ) -> Dict[str, Any]:
      """Gets the DS config dictionary after merging with overwrite values.
  
      Follows the rules as described here:
      https://docs.determined.ai/latest/training/apis-howto/deepspeed/deepspeed.html#configuration
      Args:
          hparams (Dict):
              Hyperparameters dictionary
          base_dir (pathlib.Path):
              Base directory reltative to which hparams.deepspeed_config is defined
      Returns:
          The Deepspeed Configuration for this experiment following the overwriting rules
      """
      assert _defaults.CONFIG_KEY in hparams, (
          f"Expected to find {_defaults.CONFIG_KEY} in the Hyperparameters section. "
          f"Instead found {hparams}"
      )
      ds_config_relative_path = hparams[_defaults.CONFIG_KEY]
      base_dir = pathlib.Path(base_dir)
      full_path = base_dir.joinpath(ds_config_relative_path)
      with open(full_path, "r") as f:
          base_ds_config: Dict[str, Any] = json.load(f)
      overwrite_ds_config = hparams.get(_defaults.OVERWRITE_KEY, {})
      final_ds_config = merge_dicts(base_ds_config, overwrite_ds_config)
      return final_ds_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 12 for calling a global function with example usage: get_ds_config_from_hparams(hparams, base_dir) and returns: final_ds_config