code: def get_dict_from_yaml_or_json_path(
      path: str, convert_json_keys_to_int: bool = True
  ) -> Dict[Any, Any]:
      """
      Load a json or yaml file as a dict. Optionally convert all json dict keys to
      ints, where possible.
      """
      p = pathlib.Path(path)
      if p.suffix == ".json":
          try:
              with open(p, "r") as f:
                  json_dict: Dict[Any, Any] = json.load(f)
              if convert_json_keys_to_int:
  
                  def try_str_to_int(s: str) -> Union[str, int]:
                      try:
                          return int(s)
                      except ValueError:
                          return s
  
                  json_dict = {
                      try_str_to_int(k): v for k, v in json_dict.items()
                  }
              return json_dict
          except Exception as e:
              logger.info(
                  f"Exception {e} raised when loading {path} with json. Attempting yaml."
              )
              return {}
      else:
          with open(p, "r") as f:
              yaml_dict: Dict[Any, Any] = util.yaml_safe_load(f)
          return yaml_dict
  
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 6 for calling a global function with example usage: get_dict_from_yaml_or_json_path(path, convert_json_keys_to_int) and returns: yaml_dict, json_dict, dict, int, s