



"""simple docstring"""





from typing import List

from .keymap import KEYMAP, get_character
def 						__lowerCAmelCase    (		__UpperCamelCase   :      str     ):


						'''simple docstring'''






						def decorator(__UpperCamelCase   :      List[Any]     ):
												snake_case_ :			int            =      getattr(__UpperCamelCase       ,			"""handle_key"""       ,			[]     )
												handle += [key]
												setattr(__UpperCamelCase       ,			"""handle_key"""       ,			__UpperCamelCase     )
												return func

						return decorator
def 						__lowerCAmelCase    (		*__UpperCamelCase   :      List[str]     ):


						'''simple docstring'''






						def decorator(__UpperCamelCase   :      List[Any]     ):
												snake_case_ :			Optional[Any]            =      getattr(__UpperCamelCase       ,			"""handle_key"""       ,			[]     )
												handle += keys
												setattr(__UpperCamelCase       ,			"""handle_key"""       ,			__UpperCamelCase     )
												return func

						return decorator



class  _lowerCAmelCase     (					SCREAMING_SNAKE_CASE__		):





		"""simple docstring"""






		def __new__(       cls				,     _lowercase				,     _lowercase				,     _lowercase )			->    str:







								'''simple docstring'''

								snake_case_ :			str            =      super().__new__(cls				,     _lowercase				,     _lowercase				,     _lowercase )
								if not hasattr(_lowercase				,     """key_handler""" ):
														setattr(_lowercase				,     """key_handler"""				,     {} )
								setattr(_lowercase				,     """handle_input"""				,     KeyHandler.handle_input )

								for value in attrs.values():
														snake_case_ :			Optional[Any]            =      getattr(_lowercase				,     """handle_key"""				,     [] )
														for key in handled_keys:
																				snake_case_ :			Optional[Any]            =      value
								return new_cls





		@staticmethod
		def  UpperCAmelCase__				(       cls )			->    Optional[int]:







								'''simple docstring'''

								snake_case_ :			Optional[Any]            =      get_character()
								if char != KEYMAP["undefined"]:
														snake_case_ :			List[Any]            =      ord(_lowercase )
								snake_case_ :			int            =      cls.key_handler.get(_lowercase )
								if handler:
														snake_case_ :			Tuple            =      char
														return handler(cls )
								else:
														return None




def 						__lowerCAmelCase    (		cls   :      Dict     ):


						'''simple docstring'''






						return KeyHandler(cls.__name__       ,			cls.__bases__       ,			cls.__dict__.copy()     )



"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


__SCREAMING_SNAKE_CASE							=     {
    'configuration_mega': ['MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegaConfig', 'MegaOnnxConfig'],
}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __SCREAMING_SNAKE_CASE							=     [
     'MEGA_PRETRAINED_MODEL_ARCHIVE_LIST',
     'MegaForCausalLM',
     'MegaForMaskedLM',
     'MegaForMultipleChoice',
     'MegaForQuestionAnswering',
     'MegaForSequenceClassification',
     'MegaForTokenClassification',
     'MegaModel',
     'MegaPreTrainedModel',
 ]

if TYPE_CHECKING:
 from .configuration_mega import MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP, MegaConfig, MegaOnnxConfig

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_mega import (
      MEGA_PRETRAINED_MODEL_ARCHIVE_LIST,
      MegaForCausalLM,
      MegaForMaskedLM,
      MegaForMultipleChoice,
      MegaForQuestionAnswering,
      MegaForSequenceClassification,
      MegaForTokenClassification,
      MegaModel,
      MegaPreTrainedModel,
  )

else:
 import sys

 __SCREAMING_SNAKE_CASE							=     _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)
