code: def _union_from_json(subclasses, json_obj):
      if not _is_dict(json_obj):
          raise IncorrectTypeError(
              f"incorrect Union value {json_obj} for union {subclasses}"
          )
      subclasses_dict = build_subclass_dict(subclasses)
  
      type_name = list(json_obj)[0].lower()
      if len(json_obj) == 1 and type_name in subclasses_dict:
          json_obj = next(iter(json_obj.values()))
      else:
          type_name = next(iter(subclasses_dict))
          eprint(
              "WARNING - Can not find class type in json: "
              f"trying with first class {type_name} in the union."
          )
      try:
          return _value_from_json(subclasses_dict[type_name], json_obj)
      except Exception as e:
          raise UnionTypeError(
              (
                  f"failed to parse union {subclasses} from"
                  f"json payload {json_obj} \n"
                  f"Reason: {e}"
              )
          ) from e
  
imports: from enum import Enum
  from typing import Any, Dict, List, Tuple, Type, Union
  from pytext.common.utils import eprint
  from .component import Registry
  from .config_adapter import upgrade_to_latest
  from .pytext_config import PyTextConfig
label_desc: Use image node_id 5 for calling a global function with example usage: _union_from_json(subclasses, json_obj) and returns: _value_from_json