code: def cast_str(to_type, value):
      if type(value) != str:
          return value
      if to_type == int:
          return int(value)
      elif to_type == float:
          return float(value)
      elif to_type == str:
          return value
      elif to_type == bool:
          if value.lower() in ("yes", "true", "t", "1"):
              return True
          elif value.lower() in ("no", "false", "f", "0", ""):
              return False
          else:
              raise Exception(f'Not a boolean value: "{value}"')
      elif getattr(to_type, "__origin__", None) in (list, List):
          return [
              cast_str(to_type.__args__[0], v.strip())
              for v in value.split(",")
          ]
      elif getattr(to_type, "__origin__", None) in (dict, Dict):
          key_type, value_type = to_type.__args__
          ret = {}
          for entry in value.split(","):
              k, v = entry.split(":")
              typed_k = cast_str(key_type, k)
              typed_v = cast_str(value_type, v)
              ret[typed_k] = typed_v
          return ret
      else:
          raise Exception(f"Unsupported type: {to_type}")
  
imports: from typing import Dict, List, Union
label_desc: Use image node_id 4 for calling a global function with example usage: cast_str(to_type, value) and returns: value, int, float, value, True, unknown, False, ret