
'''simple docstring'''

from typing import Callable, Optional, Union

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


UpperCAmelCase__				:	Union[str, Any]					=						logging.get_logger(__name__)

UpperCAmelCase__				:	List[str]					=						{
    "microsoft/prophetnet-large-uncased": (
        "https://huggingface.co/microsoft/prophetnet-large-uncased/resolve/main/config.json"
    ),
}






class 				A       (		__lowerCamelCase      ):
	snake_case__ :List[Any]				       =       "prophetnet"
	snake_case__ :Dict				       =       ["past_key_values"]
	snake_case__ :Any				       =       {
	    "num_attention_heads": "num_encoder_attention_heads",
	}





	def __init__(   self     :    Optional[int] ,							__magic_name__     :    Optional[float] = 0.1 ,							__magic_name__     :    Optional[Union[str, Callable]] = "gelu" ,							__magic_name__     :    Optional[int] = 30522 ,							__magic_name__     :    Optional[int] = 1024 ,							__magic_name__     :    Optional[int] = 4096 ,							__magic_name__     :    Optional[int] = 12 ,							__magic_name__     :    Optional[int] = 16 ,							__magic_name__     :    Optional[int] = 4096 ,							__magic_name__     :    Optional[int] = 12 ,							__magic_name__     :    Optional[int] = 16 ,							__magic_name__     :    Optional[float] = 0.1 ,							__magic_name__     :    Optional[float] = 0.1 ,							__magic_name__     :    Optional[int] = 512 ,							__magic_name__     :    Optional[float] = 0.02 ,							__magic_name__     :    Optional[bool] = True ,							__magic_name__     :    Optional[bool] = True ,							__magic_name__     :    Optional[int] = 0 ,							__magic_name__     :    Optional[int] = 2 ,							__magic_name__     :    Optional[int] = 32 ,							__magic_name__     :    Optional[int] = 128 ,							__magic_name__     :    Optional[bool] = False ,							__magic_name__     :    Optional[float] = 0.0 ,							__magic_name__     :    Optional[bool] = True ,							__magic_name__     :    Optional[int] = 0 ,							__magic_name__     :    Optional[int] = 1 ,							__magic_name__     :    Optional[int] = 2 ,							**__magic_name__     :    str ,							):


				"""simple docstring"""

				lowerCAmelCase__									=							vocab_size
				lowerCAmelCase__									=							hidden_size
				lowerCAmelCase__									=							encoder_ffn_dim
				lowerCAmelCase__									=							num_encoder_layers
				lowerCAmelCase__									=							num_encoder_attention_heads
				lowerCAmelCase__									=							decoder_ffn_dim
				lowerCAmelCase__									=							num_decoder_layers
				lowerCAmelCase__									=							num_decoder_attention_heads
				lowerCAmelCase__									=							max_position_embeddings
				lowerCAmelCase__									=							init_std  # Normal(0, this parameter)
				lowerCAmelCase__									=							activation_function

				# parameters for prophetnet
				lowerCAmelCase__									=							ngram
				lowerCAmelCase__									=							num_buckets
				lowerCAmelCase__									=							relative_max_distance
				lowerCAmelCase__									=							disable_ngram_loss
				lowerCAmelCase__									=							eps

				# 3 Types of Dropout
				lowerCAmelCase__									=							attention_dropout
				lowerCAmelCase__									=							activation_dropout
				lowerCAmelCase__									=							dropout

				lowerCAmelCase__									=							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 							__SCREAMING_SNAKE_CASE					(   self     :    int							):


				"""simple docstring"""

				return self.num_encoder_layers + self.num_decoder_layers







	@num_hidden_layers.setter
	def 							__SCREAMING_SNAKE_CASE					(   self     :    Any ,							__magic_name__     :    int							):


				"""simple docstring"""

				raise NotImplementedError(
				    "This model does not support the setting of `num_hidden_layers`. Please set `num_encoder_layers` and"
				    " `num_decoder_layers`."							)







'''simple docstring'''

# this script builds a small sample spm file tests/fixtures/test_sentencepiece_no_bos.model, with features needed by pegasus

# 1. pip install sentencepiece
#
# 2. wget https://raw.githubusercontent.com/google/sentencepiece/master/data/botchan.txt

# 3. build
import sentencepiece as spm

# pegasus:
# 1. no bos
# 2. eos_id is 1
# 3. unk_id is 2
# build a sample spm file accordingly
spm.SentencePieceTrainer.train(
    "--input=botchan.txt --model_prefix=test_sentencepiece_no_bos --bos_id=-1 --unk_id=2  --eos_id=1  --vocab_size=1000"
)

# 4. now update the fixture
# mv test_sentencepiece_no_bos.model ../../tests/fixtures/





