code: def cast_basic_type(value, type_str):
      if not type_str:
          # empty string with no type is treated as None
          if value == "":
              return None
          return value
  
      basic_types = {
          str(getattr(v, "__name__", v)): v
          for v in (float, int, str, list, tuple, dict)
      }
      basic_types["bool"] = convert_bool
  
      parts = type_str.split("/")
      # nested = len(parts) > 1
  
      if parts[0] in ("list", "tuple", "dict"):
          # noinspection PyBroadException
          try:
              # lists/tuple/dicts should be json loadable
              return basic_types.get(parts[0])(json.loads(value))
          except Exception:
              # noinspection PyBroadException
              try:
                  # fallback to legacy basic type loading
                  v = "[" + value.lstrip("[(").rstrip("])") + "]"
                  v = yaml.load(v, Loader=yaml.SafeLoader)
                  return basic_types.get(parts[0])(v)
              except Exception:
                  getLogger().warning(
                      "Could not cast `{}` to basic type. Returning it as `str`".format(
                          value
                      )
                  )
                  return value
  
      t = basic_types.get(str(type_str).lower().strip(), False)
      if t is not False:
          # noinspection PyBroadException
          try:
              return t(value)
          except Exception:
              return value
  
      return value
  
imports: import itertools
  import json
  from copy import copy
  from logging import getLogger
  import six
  import yaml
label_desc: Use image node_id 3 for calling a global function with example usage: cast_basic_type(value, type_str) and returns: value, value, None, basic_types, t, value, basic_types, value