code: def _parse_magic(val):
      # attempt to treat string as a json
      not_set = {}
      if val is None:
          return _magic_defaults, not_set
      if val.startswith("{"):
          try:
              val = json.loads(val)
          except ValueError:
              wandb.termwarn("Unable to parse magic json", repeat=False)
              return _magic_defaults, not_set
          conf = _merge_dicts(_magic_defaults, {})
          return _merge_dicts(val, conf), val
      if os.path.isfile(val):
          try:
              with open(val) as stream:
                  val = yaml.safe_load(stream)
          except OSError as e:
              wandb.termwarn(
                  "Unable to read magic config file", repeat=False
              )
              return _magic_defaults, not_set
          except yaml.YAMLError as e:
              wandb.termwarn(
                  "Unable to parse magic yaml file", repeat=False
              )
              return _magic_defaults, not_set
          conf = _merge_dicts(_magic_defaults, {})
          return _merge_dicts(val, conf), val
      # parse as a list of key value pairs
      if val.find("=") > 0:
          # split on commas but ignore commas inside quotes
          # Using this re allows env variable parsing like:
          # WANDB_MAGIC=key1='"["cat","dog","pizza"]"',key2=true
          items = re.findall(r'(?:[^\s,"]|"(?:\\.|[^"])*")+', val)
          conf_set = {}
          for kv in items:
              kv = kv.split("=")
              if len(kv) != 2:
                  wandb.termwarn(
                      "Unable to parse magic key value pair",
                      repeat=False,
                  )
                  continue
              d = _dict_from_keyval(*kv)
              _merge_dicts(d, conf_set)
          conf = _merge_dicts(_magic_defaults, {})
          return _merge_dicts(conf_set, conf), conf_set
      wandb.termwarn("Unable to parse magic parameter", repeat=False)
      return _magic_defaults, not_set
  
imports: import argparse
  import copy
  import json
  import os
  import re
  import sys
  import yaml
  import wandb
  from wandb import trigger
  from wandb.util import add_import_hook, get_optional_module
label_desc: Use image node_id 4 for calling a global function with example usage: _parse_magic(val) and returns: _magic_defaults,  not_set, _magic_defaults,  not_set, _merge_dicts,  val, _merge_dicts,  val, _merge_dicts,  conf_set, _magic_defaults,  not_set, _magic_defaults,  not_set, _magic_defaults,  not_set