code: def _enum_from_json(enum_cls, json_obj):
      for e in enum_cls:
          if e.value == json_obj:
              return e
      raise EnumTypeError(
          f"invalid enum value {json_obj} for {enum_cls}"
      )
  
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 7 for calling a global function with example usage: _enum_from_json(enum_cls, json_obj) and returns: e