code: def _value_to_json(cls, value):
      cls_type = _get_class_type(cls)
      assert _is_optional(cls) or value is not None
      if value is None:
          return value
      elif _is_optional(cls) and len(cls.__args__) == 2:
          sub_cls = (
              cls.__args__[0]
              if type(None) != cls.__args__[0]
              else cls.__args__[1]
          )
          return _value_to_json(sub_cls, value)
      elif cls_type == Union:
          real_cls = type(value)
          if hasattr(real_cls, "_fields"):
              value = config_to_json(real_cls, value)
  
          if issubclass(real_cls, str):
              name = "string_value"
          elif issubclass(real_cls, int):
              name = "int_value"
          elif issubclass(real_cls, float):
              name = "double_value"
          elif issubclass(real_cls, List):
              if len(value) == 0:
                  raise TypeError(
                      f"Can not properly decide the type of {value} since it is empty"
                  )
              real_cls = type(value[0])
              if issubclass(real_cls, str):
                  name = "list_string_value"
              elif issubclass(real_cls, int):
                  name = "list_int_value"
              elif issubclass(real_cls, float):
                  name = "list_double_value"
              else:
                  raise TypeError(f"{real_cls} type not supported")
          elif issubclass(real_cls, Dict):
              if len(value) == 0:
                  raise TypeError(
                      f"Can not properly decide the type of {value} since it is empty"
                  )
              items = list(value.items())
              key_real_cls, value_real_cls = type(items[0][0]), type(
                  items[0][1]
              )
              if not issubclass(key_real_cls, str):
                  raise TypeError(f"{value} type not supported")
              if issubclass(value_real_cls, str):
                  name = "map_string_value"
              elif issubclass(value_real_cls, int):
                  name = "map_int_value"
              elif issubclass(value_real_cls, float):
                  name = "map_double_value"
              else:
                  raise TypeError(f"{real_cls} type not supported")
          else:
              raise TypeError(f"{real_cls} type not supported")
          return {name: value}
      elif hasattr(cls, "_fields"):
          return config_to_json(cls, value)
      elif issubclass(cls_type, Enum):
          return value.value
      elif issubclass(cls_type, List):
          sub_cls = cls.__args__[0]
          return [_value_to_json(sub_cls, v) for v in value]
      elif issubclass(cls_type, Tuple):
          return tuple(
              _value_to_json(c, v)
              for c, v in zip(_extend_tuple_type(cls, value), value)
          )
      elif issubclass(cls_type, Dict):
          sub_cls = cls.__args__[1]
          return {
              key: _value_to_json(sub_cls, v)
              for key, v in value.items()
          }
      return value
  
imports: from enum import Enum
  from typing import Dict, List, Tuple, Union
label_desc: Use image node_id 4 for calling a global function with example usage: _value_to_json(cls, value) and returns: value, value, _value_to_json, dict, config_to_json, value, unknown, tuple, unknown