





from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCAmelCase_           =	logging.get_logger(__name__)

UpperCAmelCase_           =	{
    "weiweishi/roc-bert-base-zh": "https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json",
}




class 			__UpperCamelCase    (							A__    ):
     __A	:  List[Any]							  =   """roc_bert"""





     def __init__(     self				,							_UpperCamelCase=30522				,							_UpperCamelCase=768				,							_UpperCamelCase=12				,							_UpperCamelCase=12				,							_UpperCamelCase=3072				,							_UpperCamelCase="gelu"				,							_UpperCamelCase=0.1				,							_UpperCamelCase=0.1				,							_UpperCamelCase=512				,							_UpperCamelCase=2				,							_UpperCamelCase=0.02				,							_UpperCamelCase=1e-12				,							_UpperCamelCase=True				,							_UpperCamelCase=0				,							_UpperCamelCase="absolute"				,							_UpperCamelCase=None				,							_UpperCamelCase=True				,							_UpperCamelCase=True				,							_UpperCamelCase=768				,							_UpperCamelCase=910				,							_UpperCamelCase=512				,							_UpperCamelCase=24858				,							_UpperCamelCase=True				,							**_UpperCamelCase				,							):
        _UpperCAmelCase           =   vocab_size
        _UpperCAmelCase           =   max_position_embeddings
        _UpperCAmelCase           =   hidden_size
        _UpperCAmelCase           =   num_hidden_layers
        _UpperCAmelCase           =   num_attention_heads
        _UpperCAmelCase           =   intermediate_size
        _UpperCAmelCase           =   hidden_act
        _UpperCAmelCase           =   hidden_dropout_prob
        _UpperCAmelCase           =   attention_probs_dropout_prob
        _UpperCAmelCase           =   initializer_range
        _UpperCAmelCase           =   type_vocab_size
        _UpperCAmelCase           =   layer_norm_eps
        _UpperCAmelCase           =   use_cache
        _UpperCAmelCase           =   enable_pronunciation
        _UpperCAmelCase           =   enable_shape
        _UpperCAmelCase           =   pronunciation_embed_dim
        _UpperCAmelCase           =   pronunciation_vocab_size
        _UpperCAmelCase           =   shape_embed_dim
        _UpperCAmelCase           =   shape_vocab_size
        _UpperCAmelCase           =   concat_input
        _UpperCAmelCase           =   position_embedding_type
        _UpperCAmelCase           =   classifier_dropout
        super().__init__(pad_token_id=_UpperCamelCase				,							**_UpperCamelCase					)






from typing import List

from .keymap import KEYMAP, get_character
def      A__       (    SCREAMING_SNAKE_CASE_   :      str						)  ->  List[str]:






   """simple docstring"""







   def decorator(SCREAMING_SNAKE_CASE_   :      List[Any]						):
      _UpperCAmelCase           =   getattr(SCREAMING_SNAKE_CASE_				,	'''handle_key'''				,	[]						)
      handle += [key]
      setattr(SCREAMING_SNAKE_CASE_				,	'''handle_key'''				,	SCREAMING_SNAKE_CASE_						)
      return func

   return decorator
def      A__       (    *SCREAMING_SNAKE_CASE_   :      List[str]						)  ->  Dict:






   """simple docstring"""







   def decorator(SCREAMING_SNAKE_CASE_   :      Any						):
      _UpperCAmelCase           =   getattr(SCREAMING_SNAKE_CASE_				,	'''handle_key'''				,	[]						)
      handle += keys
      setattr(SCREAMING_SNAKE_CASE_				,	'''handle_key'''				,	SCREAMING_SNAKE_CASE_						)
      return func

   return decorator




class 			__UpperCamelCase    (							A__    ):





     def __new__(     cls				,							_UpperCamelCase				,							_UpperCamelCase				,							_UpperCamelCase					):
        _UpperCAmelCase           =   super().__new__(cls				,							_UpperCamelCase				,							_UpperCamelCase				,							_UpperCamelCase					)
        if not hasattr(_UpperCamelCase				,							'''key_handler'''					):
           setattr(_UpperCamelCase				,							'''key_handler'''				,							{}					)
        setattr(_UpperCamelCase				,							'''handle_input'''				,							KeyHandler.handle_input					)

        for value in attrs.values():
           _UpperCAmelCase           =   getattr(_UpperCamelCase				,							'''handle_key'''				,							[]					)
           for key in handled_keys:
              _UpperCAmelCase           =   value
        return new_cls





     @staticmethod
     def 		UpperCamelCase(     cls					):
        _UpperCAmelCase           =   get_character()
        if char != KEYMAP["undefined"]:
           _UpperCAmelCase           =   ord(_UpperCamelCase					)
        _UpperCAmelCase           =   cls.key_handler.get(_UpperCamelCase					)
        if handler:
           _UpperCAmelCase           =   char
           return handler(cls					)
        else:
           return None




def      A__       (    cls   :      Union[str, Any]						)  ->  Any:






   """simple docstring"""







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