code: def decode_sagemaker_parameter(value: str) -> Union[list, dict, str]:
      """
      All values passed through the SageMaker API are encoded as strings. Thus we
      pro-actively decode values that seem like arrays or dicts.
  
      Integer values (e.g. `"1"`) are handled by pydantic models further down the
      pipeline.
      """
      value = value.strip()
  
      # TODO: is this the right way to do things?
      #       what about fields which start which match the pattern for
      #       some reason?
      is_list = value.startswith("[") and value.endswith("]")
      is_dict = value.startswith("{") and value.endswith("}")
  
      if is_list or is_dict:
          return load_json(value)
      else:
          return value
  
file_path: gluonts/src/gluonts/shell/sagemaker/params.py
imports: from itertools import count
  from typing import Any, Union
  from toolz import valmap
  from gluonts.core.serde import dump_json, load_json
  from gluonts.itertools import batcher
label_desc: Use image node_id 1 for calling a global function with example usage: decode_sagemaker_parameter(value) and returns: load_json, value