



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


_lowercase     							=						logging.get_logger(__name__)

_lowercase     							=						{
    '''facebook/nllb-moe-54B''': '''https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json''',
}
class 				__A					( A_      ):
			UpperCamelCase					:Any     =			'''nllb-moe'''
			UpperCamelCase					:Tuple     =			['''past_key_values''']
			UpperCamelCase					:Any     =			{'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}





			def __init__(self							,    __magic_name__=128112							,    __magic_name__=1024							,    __magic_name__=12							,    __magic_name__=4096							,    __magic_name__=16							,    __magic_name__=12							,    __magic_name__=4096							,    __magic_name__=16							,    __magic_name__=0.05							,    __magic_name__=0.05							,    __magic_name__=True							,    __magic_name__=True							,    __magic_name__="relu"							,    __magic_name__=1024							,    __magic_name__=0.1							,    __magic_name__=0.1							,    __magic_name__=0.0							,    __magic_name__=0.02							,    __magic_name__=2							,    __magic_name__=True							,    __magic_name__=False							,    __magic_name__="float32"							,    __magic_name__=False							,    __magic_name__=128							,    __magic_name__=64							,    __magic_name__=4							,    __magic_name__=4							,    __magic_name__=0.0_01							,    __magic_name__=0.0_01							,    __magic_name__="all"							,    __magic_name__=False							,    __magic_name__=False							,    __magic_name__=1.0							,    __magic_name__=0.2							,    __magic_name__=1							,    __magic_name__=0							,    __magic_name__=2							,    __magic_name__=False							,    **__magic_name__							,    ):
						lowerCamelCase__ :      Dict								=		vocab_size
						lowerCamelCase__ :      int								=		max_position_embeddings
						lowerCamelCase__ :      str								=		d_model
						lowerCamelCase__ :      Optional[int]								=		encoder_ffn_dim
						lowerCamelCase__ :      Union[str, Any]								=		encoder_layers
						lowerCamelCase__ :      List[Any]								=		encoder_attention_heads
						lowerCamelCase__ :      Union[str, Any]								=		decoder_ffn_dim
						lowerCamelCase__ :      Optional[Any]								=		decoder_layers
						lowerCamelCase__ :      List[Any]								=		decoder_attention_heads
						lowerCamelCase__ :      Dict								=		dropout
						lowerCamelCase__ :      Optional[int]								=		attention_dropout
						lowerCamelCase__ :      Optional[int]								=		activation_dropout
						lowerCamelCase__ :      Optional[Any]								=		activation_function
						lowerCamelCase__ :      int								=		init_std
						lowerCamelCase__ :      str								=		encoder_layerdrop
						lowerCamelCase__ :      Dict								=		decoder_layerdrop
						lowerCamelCase__ :      List[Any]								=		use_cache
						lowerCamelCase__ :      Dict								=		encoder_layers
						lowerCamelCase__ :      Union[str, Any]								=		scale_embedding  # scale factor will be sqrt(d_model) if True
						lowerCamelCase__ :      Optional[Any]								=		router_z_loss_coef
						lowerCamelCase__ :      Tuple								=		router_aux_loss_coef
						lowerCamelCase__ :      Optional[int]								=		decoder_sparse_step
						lowerCamelCase__ :      Optional[Any]								=		encoder_sparse_step
						lowerCamelCase__ :      Union[str, Any]								=		num_experts
						lowerCamelCase__ :      int								=		expert_capacity
						lowerCamelCase__ :      Tuple								=		router_bias
						if router_dtype not in ["float32", "float16", "bfloat16"]:
									raise ValueError(f"`router_dtype` must be one of 'float32', 'float16' or 'bfloat16', got {router_dtype}"				)
						lowerCamelCase__ :      List[str]								=		router_dtype

						lowerCamelCase__ :      str								=		router_ignore_padding_tokens
						lowerCamelCase__ :      int								=		batch_prioritized_routing
						lowerCamelCase__ :      List[Any]								=		second_expert_policy
						lowerCamelCase__ :      Dict								=		normalize_router_prob_before_dropping
						lowerCamelCase__ :      Any								=		moe_eval_capacity_token_fraction
						lowerCamelCase__ :      Optional[Any]								=		moe_token_dropout
						lowerCamelCase__ :      Dict								=		output_router_logits
						super().__init__(
						    pad_token_id=__magic_name__							,    bos_token_id=__magic_name__							,    eos_token_id=__magic_name__							,    is_encoder_decoder=__magic_name__							,    decoder_start_token_id=__magic_name__							,    **__magic_name__							,    )








import itertools
import string
from collections.abc import Generator, Iterable






def      _A				(UpperCamelCase		:      Iterable[str]      ,			UpperCamelCase		:      int )  ->Generator[tuple[str, ...], None, None]:



			'''simple docstring'''







			lowerCamelCase__ :      Any								=		iter(UpperCamelCase )
			while True:
						lowerCamelCase__ :      Union[str, Any]								=		tuple(itertools.islice(UpperCamelCase      ,			UpperCamelCase ) )
						if not chunk:
									return
						yield chunk






def      _A				(UpperCamelCase		:      str )  ->str:



			'''simple docstring'''







			lowerCamelCase__ :      Tuple								=		"""""".join([c.upper() for c in dirty if c in string.ascii_letters] )
			lowerCamelCase__ :      Any								=		""""""

			if len(UpperCamelCase ) < 2:
						return dirty

			for i in range(len(UpperCamelCase ) - 1 ):
						clean += dirty[i]

						if dirty[i] == dirty[i + 1]:
									clean += "X"

			clean += dirty[-1]

			if len(UpperCamelCase ) & 1:
						clean += "X"

			return clean






def      _A				(UpperCamelCase		:      str )  ->list[str]:



			'''simple docstring'''







			lowerCamelCase__ :      Optional[Any]								=		"""ABCDEFGHIKLMNOPQRSTUVWXYZ"""
			# we're using a list instead of a '2d' array because it makes the math
			# for setting up the table and doing the actual encoding/decoding simpler
			lowerCamelCase__ :      List[Any]								=		[]

			# copy key chars into the table if they are in `alphabet` ignoring duplicates
			for char in key.upper():
						if char not in table and char in alphabet:
									table.append(UpperCamelCase )

    # fill the rest of the table in with the remaining alphabet chars
			for char in alphabet:
						if char not in table:
									table.append(UpperCamelCase )

			return table






def      _A				(UpperCamelCase		:      str      ,			UpperCamelCase		:      str )  ->str:



			'''simple docstring'''







			lowerCamelCase__ :      Tuple								=		generate_table(UpperCamelCase )
			lowerCamelCase__ :      int								=		prepare_input(UpperCamelCase )
			lowerCamelCase__ :      List[str]								=		""""""

			# https://en.wikipedia.org/wiki/Playfair_cipher#Description
			for chara, chara in chunker(UpperCamelCase      ,			2 ):
						lowerCamelCase__							,lowerCamelCase__ :      Optional[Any]								=		divmod(table.index(UpperCamelCase )      ,			5 )
						lowerCamelCase__							,lowerCamelCase__ :      Optional[Any]								=		divmod(table.index(UpperCamelCase )      ,			5 )

						if rowa == rowa:
									ciphertext += table[rowa * 5 + (cola + 1) % 5]
									ciphertext += table[rowa * 5 + (cola + 1) % 5]
						elif cola == cola:
									ciphertext += table[((rowa + 1) % 5) * 5 + cola]
									ciphertext += table[((rowa + 1) % 5) * 5 + cola]
						else:  # rectangle
									ciphertext += table[rowa * 5 + cola]
									ciphertext += table[rowa * 5 + cola]

			return ciphertext






def      _A				(UpperCamelCase		:      str      ,			UpperCamelCase		:      str )  ->str:



			'''simple docstring'''







			lowerCamelCase__ :      Any								=		generate_table(UpperCamelCase )
			lowerCamelCase__ :      Any								=		""""""

			# https://en.wikipedia.org/wiki/Playfair_cipher#Description
			for chara, chara in chunker(UpperCamelCase      ,			2 ):
						lowerCamelCase__							,lowerCamelCase__ :      int								=		divmod(table.index(UpperCamelCase )      ,			5 )
						lowerCamelCase__							,lowerCamelCase__ :      Any								=		divmod(table.index(UpperCamelCase )      ,			5 )

						if rowa == rowa:
									plaintext += table[rowa * 5 + (cola - 1) % 5]
									plaintext += table[rowa * 5 + (cola - 1) % 5]
						elif cola == cola:
									plaintext += table[((rowa - 1) % 5) * 5 + cola]
									plaintext += table[((rowa - 1) % 5) * 5 + cola]
						else:  # rectangle
									plaintext += table[rowa * 5 + cola]
									plaintext += table[rowa * 5 + cola]

			return plaintext



