
'''simple docstring'''


from typing import Dict, List, Optional, Tuple

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


__SCREAMING_SNAKE_CASE						=      logging.get_logger(__name__)




class     __snake_case			(    a__	):
		a_          =					["input_ids", "attention_mask"]




		def __init__(  self					:Tuple			,    _SCREAMING_SNAKE_CASE					:List[Any]="[PAD]"			,    _SCREAMING_SNAKE_CASE					:Any="[BOS]"			,    _SCREAMING_SNAKE_CASE					:Dict="[EOS]"			,    _SCREAMING_SNAKE_CASE					:List[str]="[MASK]"			,    _SCREAMING_SNAKE_CASE					:Union[str, Any]="[CLS]"			,    _SCREAMING_SNAKE_CASE					:str="[SEP]"			,    _SCREAMING_SNAKE_CASE					:Tuple=2_0_4_8			,    **_SCREAMING_SNAKE_CASE					:Dict			,    )					->			Tuple:






								'''simple docstring'''






								UpperCamelCase_     :	str					     =     AddedToken(UpperCamelCase_			,    lstrip=UpperCamelCase_			,    rstrip=UpperCamelCase_) if isinstance(UpperCamelCase_			,    UpperCamelCase_) else pad_token
								UpperCamelCase_     :	Union[str, Any]					     =     AddedToken(UpperCamelCase_			,    lstrip=UpperCamelCase_			,    rstrip=UpperCamelCase_) if isinstance(UpperCamelCase_			,    UpperCamelCase_) else bos_token
								UpperCamelCase_     :	int					     =     AddedToken(UpperCamelCase_			,    lstrip=UpperCamelCase_			,    rstrip=UpperCamelCase_) if isinstance(UpperCamelCase_			,    UpperCamelCase_) else eos_token
								UpperCamelCase_     :	Union[str, Any]					     =     AddedToken(UpperCamelCase_			,    lstrip=UpperCamelCase_			,    rstrip=UpperCamelCase_) if isinstance(UpperCamelCase_			,    UpperCamelCase_) else mask_token
								UpperCamelCase_     :	List[str]					     =     AddedToken(UpperCamelCase_			,    lstrip=UpperCamelCase_			,    rstrip=UpperCamelCase_) if isinstance(UpperCamelCase_			,    UpperCamelCase_) else cls_token
								UpperCamelCase_     :	Dict					     =     AddedToken(UpperCamelCase_			,    lstrip=UpperCamelCase_			,    rstrip=UpperCamelCase_) if isinstance(UpperCamelCase_			,    UpperCamelCase_) else sep_token

								super().__init__(
								    pad_token=UpperCamelCase_			,    bos_token=UpperCamelCase_			,    eos_token=UpperCamelCase_			,    mask_token=UpperCamelCase_			,    cls_token=UpperCamelCase_			,    sep_token=UpperCamelCase_			,    model_max_length=UpperCamelCase_			,    **UpperCamelCase_			,    )

								UpperCamelCase_     :	Optional[int]					     =     2**8  # utf is 8 bits

								# define special tokens dict
								UpperCamelCase_     :	Dict[str, int]					     =     {
								    self.pad_token: 0,
								    self.bos_token: 1,
								    self.eos_token: 2,
								    self.mask_token: 3,
								    self.cls_token: 4,
								    self.sep_token: 5,
								}
								UpperCamelCase_     :	int					     =     len(self.special_tokens_encoder)
								UpperCamelCase_     :	Dict[int, str]					     =     {v: k for k, v in self.special_tokens_encoder.items()}




		def 	_snake_case	(  self					:List[str])					->			Union[str, Any]:






								'''simple docstring'''






								UpperCamelCase_     :	Optional[Any]					     =     self.special_tokens_encoder.copy()
								vocab.update(self.added_tokens_encoder)
								for i in range(self._utf_vocab_size):
														UpperCamelCase_     :	str					     =     chr(UpperCamelCase_)
														UpperCamelCase_     :	Dict					     =     i + len(self.special_tokens_encoder)
								return vocab




		@property
		def 	_snake_case	(  self					:str)					->			Optional[Any]:






								'''simple docstring'''






								return self._utf_vocab_size + self._num_special_tokens




		def 	_snake_case	(  self					:List[str]			,    _SCREAMING_SNAKE_CASE					:List[int]			,    _SCREAMING_SNAKE_CASE					:Optional[List[int]] = None			,    _SCREAMING_SNAKE_CASE					:bool = False)					->			Any:






								'''simple docstring'''






								if already_has_special_tokens:
														return super().get_special_tokens_mask(
														    token_ids_a=UpperCamelCase_			,    token_ids_a=UpperCamelCase_			,    already_has_special_tokens=UpperCamelCase_)

								# normal case: some special tokens
								if token_ids_a is None:
														return [1] + [0] * len(UpperCamelCase_) + [1]
								return [1] + ([0] * len(UpperCamelCase_)) + [1] + ([0] * len(UpperCamelCase_)) + [1]




		def 	_snake_case	(  self					:Dict			,    _SCREAMING_SNAKE_CASE					:List[int]			,    _SCREAMING_SNAKE_CASE					:Optional[List[int]] = None)					->			Optional[int]:






								'''simple docstring'''






								if token_ids_a is None:
														return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
								else:
														return [self.cls_token_id] + token_ids_a + [self.sep_token_id] + token_ids_a + [self.sep_token_id]




		def 	_snake_case	(  self					:Union[str, Any]			,    _SCREAMING_SNAKE_CASE					:str)					->			Optional[Any]:






								'''simple docstring'''






								UpperCamelCase_     :	Optional[Any]					     =     [chr(UpperCamelCase_) for i in text.encode("""utf-8""")]
								return tokens




		def 	_snake_case	(  self					:Union[str, Any]			,    _SCREAMING_SNAKE_CASE					:Optional[int])					->			List[str]:






								'''simple docstring'''






								if token in self.special_tokens_encoder:
														UpperCamelCase_     :	Optional[Any]					     =     self.special_tokens_encoder[token]
								elif token in self.added_tokens_encoder:
														UpperCamelCase_     :	Union[str, Any]					     =     self.added_tokens_encoder[token]
								elif len(UpperCamelCase_) != 1:
														UpperCamelCase_     :	Union[str, Any]					     =     self.unk_token_id
								else:
														UpperCamelCase_     :	Any					     =     ord(UpperCamelCase_) + self._num_special_tokens
								return token_id




		def 	_snake_case	(  self					:Optional[Any]			,    _SCREAMING_SNAKE_CASE					:List[Any])					->			Dict:






								'''simple docstring'''






								if index in self.special_tokens_decoder:
														UpperCamelCase_     :	Tuple					     =     self.special_tokens_decoder[index]
								elif index in self.added_tokens_decoder:
														UpperCamelCase_     :	Optional[Any]					     =     self.added_tokens_decoder[index]
								else:
														UpperCamelCase_     :	List[Any]					     =     chr(index - self._num_special_tokens)
								return token




		def 	_snake_case	(  self					:Dict			,    _SCREAMING_SNAKE_CASE					:Optional[int])					->			str:






								'''simple docstring'''






								UpperCamelCase_     :	List[Any]					     =     b''''''
								for token in tokens:
														if token in self.special_tokens_decoder:
																				UpperCamelCase_     :	List[Any]					     =     self.special_tokens_decoder[token].encode("""utf-8""")
														elif token in self.added_tokens_decoder:
																				UpperCamelCase_     :	int					     =     self.special_tokens_decoder[token].encode("""utf-8""")
														elif token in self.special_tokens_encoder:
																				UpperCamelCase_     :	str					     =     token.encode("""utf-8""")
														elif token in self.added_tokens_encoder:
																				UpperCamelCase_     :	Tuple					     =     token.encode("""utf-8""")
														else:
																				UpperCamelCase_     :	Dict					     =     bytes([ord(UpperCamelCase_)])
														bstring += tok_string
								UpperCamelCase_     :	str					     =     bstring.decode("""utf-8"""			,    errors="""replace""")
								return string





		def 	_snake_case	(  self					:List[str]			,    _SCREAMING_SNAKE_CASE					:str			,    _SCREAMING_SNAKE_CASE					:Optional[str] = None)					->			int:






								'''simple docstring'''






								return ()








"""simple docstring"""





from typing import Callable, Optional, Union

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


snake_case__		:  Optional[Any]     					=					logging.get_logger(__name__)

snake_case__		:  str     					=					{
    '''microsoft/prophetnet-large-uncased''': (
        '''https://huggingface.co/microsoft/prophetnet-large-uncased/resolve/main/config.json'''
    ),
}



class 		snake_case_(							a__      ):
     __UpperCamelCase	=       '''prophetnet'''
     __UpperCamelCase	=       ['''past_key_values''']
     __UpperCamelCase	=       {
         '''num_attention_heads''': '''num_encoder_attention_heads''',
     }






     def __init__(						self	:       Union[str, Any]       ,					UpperCamelCase_	:       Optional[float] = 0.1       ,					UpperCamelCase_	:       Optional[Union[str, Callable]] = "gelu"       ,					UpperCamelCase_	:       Optional[int] = 3_0_5_2_2       ,					UpperCamelCase_	:       Optional[int] = 1_0_2_4       ,					UpperCamelCase_	:       Optional[int] = 4_0_9_6       ,					UpperCamelCase_	:       Optional[int] = 1_2       ,					UpperCamelCase_	:       Optional[int] = 1_6       ,					UpperCamelCase_	:       Optional[int] = 4_0_9_6       ,					UpperCamelCase_	:       Optional[int] = 1_2       ,					UpperCamelCase_	:       Optional[int] = 1_6       ,					UpperCamelCase_	:       Optional[float] = 0.1       ,					UpperCamelCase_	:       Optional[float] = 0.1       ,					UpperCamelCase_	:       Optional[int] = 5_1_2       ,					UpperCamelCase_	:       Optional[float] = 0.02       ,					UpperCamelCase_	:       Optional[bool] = True       ,					UpperCamelCase_	:       Optional[bool] = True       ,					UpperCamelCase_	:       Optional[int] = 0       ,					UpperCamelCase_	:       Optional[int] = 2       ,					UpperCamelCase_	:       Optional[int] = 3_2       ,					UpperCamelCase_	:       Optional[int] = 1_2_8       ,					UpperCamelCase_	:       Optional[bool] = False       ,					UpperCamelCase_	:       Optional[float] = 0.0       ,					UpperCamelCase_	:       Optional[bool] = True       ,					UpperCamelCase_	:       Optional[int] = 0       ,					UpperCamelCase_	:       Optional[int] = 1       ,					UpperCamelCase_	:       Optional[int] = 2       ,					**UpperCamelCase_	:       List[Any]       ,					):
           lowerCAmelCase       :						Union[str, Any]							= vocab_size
           lowerCAmelCase       :						Any							= hidden_size
           lowerCAmelCase       :						Tuple							= encoder_ffn_dim
           lowerCAmelCase       :						str							= num_encoder_layers
           lowerCAmelCase       :						int							= num_encoder_attention_heads
           lowerCAmelCase       :						Optional[Any]							= decoder_ffn_dim
           lowerCAmelCase       :						Union[str, Any]							= num_decoder_layers
           lowerCAmelCase       :						Union[str, Any]							= num_decoder_attention_heads
           lowerCAmelCase       :						List[Any]							= max_position_embeddings
           lowerCAmelCase       :						Dict							= init_std  # Normal(0, this parameter)
           lowerCAmelCase       :						Optional[int]							= activation_function

           # parameters for prophetnet
           lowerCAmelCase       :						Tuple							= ngram
           lowerCAmelCase       :						List[Any]							= num_buckets
           lowerCAmelCase       :						Optional[Any]							= relative_max_distance
           lowerCAmelCase       :						Dict							= disable_ngram_loss
           lowerCAmelCase       :						Optional[int]							= eps

           # 3 Types of Dropout
           lowerCAmelCase       :						Any							= attention_dropout
           lowerCAmelCase       :						List[Any]							= activation_dropout
           lowerCAmelCase       :						Tuple							= dropout

           lowerCAmelCase       :						Optional[int]							= use_cache

           super().__init__(
               pad_token_id=UpperCamelCase_       ,					bos_token_id=UpperCamelCase_       ,					eos_token_id=UpperCamelCase_       ,					is_encoder_decoder=UpperCamelCase_       ,					add_cross_attention=UpperCamelCase_       ,					decoder_start_token_id=UpperCamelCase_       ,					**UpperCamelCase_       ,					)






     @property
     def   lowerCamelCase__  (						self	:       str					):
           return self.num_encoder_layers + self.num_decoder_layers






     @num_hidden_layers.setter
     def   lowerCamelCase__  (						self	:       Optional[Any]       ,					UpperCamelCase_	:       int					):
           raise NotImplementedError(
               '''This model does not support the setting of `num_hidden_layers`. Please set `num_encoder_layers` and'''
               ''' `num_decoder_layers`.'''					)


