


"""simple docstring"""



import itertools
import string
from collections.abc import Generator, Iterable
def      UpperCAmelCase     (       _lowercase :   Iterable[str]			,   _lowercase :   int	)						-> Generator[tuple[str, ...], None, None]:


	"""simple docstring"""




	lowerCAmelCase_      							=			iter(_lowercase	)
	while True:
		lowerCAmelCase_      							=			tuple(itertools.islice(_lowercase			,   _lowercase	)	)
		if not chunk:
			return
		yield chunk
def      UpperCAmelCase     (       _lowercase :   str	)						-> str:


	"""simple docstring"""




	lowerCAmelCase_      							=			''''''.join([c.upper() for c in dirty if c in string.ascii_letters]	)
	lowerCAmelCase_      							=			''''''

	if len(_lowercase	) < 2:
		return dirty

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

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

	clean += dirty[-1]

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

	return clean
def      UpperCAmelCase     (       _lowercase :   str	)						-> list[str]:


	"""simple docstring"""




	lowerCAmelCase_      							=			'''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_      							=			[]

	# 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(_lowercase	)

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

	return table
def      UpperCAmelCase     (       _lowercase :   str			,   _lowercase :   str	)						-> str:


	"""simple docstring"""




	lowerCAmelCase_      							=			generate_table(_lowercase	)
	lowerCAmelCase_      							=			prepare_input(_lowercase	)
	lowerCAmelCase_      							=			''''''

	# https://en.wikipedia.org/wiki/Playfair_cipher#Description
	for chara, chara in chunker(_lowercase			,   2	):
		lowerCAmelCase_							,	lowerCAmelCase_      							=			divmod(table.index(_lowercase	)			,   5	)
		lowerCAmelCase_							,	lowerCAmelCase_      							=			divmod(table.index(_lowercase	)			,   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      UpperCAmelCase     (       _lowercase :   str			,   _lowercase :   str	)						-> str:


	"""simple docstring"""




	lowerCAmelCase_      							=			generate_table(_lowercase	)
	lowerCAmelCase_      							=			''''''

	# https://en.wikipedia.org/wiki/Playfair_cipher#Description
	for chara, chara in chunker(_lowercase			,   2	):
		lowerCAmelCase_							,	lowerCAmelCase_      							=			divmod(table.index(_lowercase	)			,   5	)
		lowerCAmelCase_							,	lowerCAmelCase_      							=			divmod(table.index(_lowercase	)			,   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



"""simple docstring"""



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


lowercase_							=							logging.get_logger(__name__)

lowercase_							=							{
    's-JoL/Open-Llama-V1': 'https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json',
}







class    __a						( __snake_case							):
				lowerCamelCase     :       Union[str, Any]			       ='open-llama'







				def __init__( self      ,	UpperCAmelCase=10_0000      ,	UpperCAmelCase=4096      ,	UpperCAmelCase=1_1008      ,	UpperCAmelCase=32      ,	UpperCAmelCase=32      ,	UpperCAmelCase="silu"      ,	UpperCAmelCase=2048      ,	UpperCAmelCase=0.0_2      ,	UpperCAmelCase=1E-6      ,	UpperCAmelCase=True      ,	UpperCAmelCase=0      ,	UpperCAmelCase=1      ,	UpperCAmelCase=2      ,	UpperCAmelCase=False      ,	UpperCAmelCase=True      ,	UpperCAmelCase=0.1      ,	UpperCAmelCase=0.1      ,	UpperCAmelCase=True      ,	UpperCAmelCase=True      ,	UpperCAmelCase=None      ,	**UpperCAmelCase      ,	):

					'''simple docstring'''






					lowerCAmelCase_      							=			vocab_size
					lowerCAmelCase_      							=			max_position_embeddings
					lowerCAmelCase_      							=			hidden_size
					lowerCAmelCase_      							=			intermediate_size
					lowerCAmelCase_      							=			num_hidden_layers
					lowerCAmelCase_      							=			num_attention_heads
					lowerCAmelCase_      							=			hidden_act
					lowerCAmelCase_      							=			initializer_range
					lowerCAmelCase_      							=			rms_norm_eps
					lowerCAmelCase_      							=			use_cache
					lowerCAmelCase_      							=			kwargs.pop(
					    '''use_memorry_efficient_attention'''      ,	UpperCAmelCase   )
					lowerCAmelCase_      							=			hidden_dropout_prob
					lowerCAmelCase_      							=			attention_dropout_prob
					lowerCAmelCase_      							=			use_stable_embedding
					lowerCAmelCase_      							=			shared_input_output_embedding
					lowerCAmelCase_      							=			rope_scaling
					self._rope_scaling_validation()

					super().__init__(
					    pad_token_id=UpperCAmelCase      ,	bos_token_id=UpperCAmelCase      ,	eos_token_id=UpperCAmelCase      ,	tie_word_embeddings=UpperCAmelCase      ,	**UpperCAmelCase      ,	)







				def      lowerCamelCase_     ( self   ):

					'''simple docstring'''






					if self.rope_scaling is None:
						return

					if not isinstance(self.rope_scaling      ,	UpperCAmelCase   ) or len(self.rope_scaling   ) != 2:
						raise ValueError(
						    '''`rope_scaling` must be a dictionary with with two fields, `name` and `factor`, '''
						    F"""got {self.rope_scaling}"""   )
					lowerCAmelCase_      							=			self.rope_scaling.get('''type'''      ,	UpperCAmelCase   )
					lowerCAmelCase_      							=			self.rope_scaling.get('''factor'''      ,	UpperCAmelCase   )
					if rope_scaling_type is None or rope_scaling_type not in ["linear", "dynamic"]:
						raise ValueError(
						    F"""`rope_scaling`'s name field must be one of ['linear', 'dynamic'], got {rope_scaling_type}"""   )
					if rope_scaling_factor is None or not isinstance(UpperCAmelCase      ,	UpperCAmelCase   ) or rope_scaling_factor <= 1.0:
						raise ValueError(F"""`rope_scaling`'s factor field must be an float > 1, got {rope_scaling_factor}"""   )