"""simple docstring"""







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


_a					:					Dict=			logging.get_logger(__name__)

_a					:					Tuple=			{
    "facebook/s2t-wav2vec2-large-en-de": (
        "https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json"
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech2text2
}

class 		UpperCamelCase      (   lowercase						):
				UpperCAmelCase    :				str   =		"""speech_to_text_2"""
				UpperCAmelCase    :				Any   =		["""past_key_values"""]
				UpperCAmelCase    :				Optional[Any]   =		{"""num_attention_heads""": """decoder_attention_heads""", """hidden_size""": """d_model"""}



				def __init__(self    :				Union[str, Any]     ,  _A    :				Optional[int]=1_00_00     ,  _A    :				List[Any]=6     ,  _A    :				Union[str, Any]=20_48     ,  _A    :				int=4     ,  _A    :				Tuple=0.0     ,  _A    :				int=True     ,  _A    :				Dict="relu"     ,  _A    :				Union[str, Any]=2_56     ,  _A    :				Tuple=0.1     ,  _A    :				str=0.0     ,  _A    :				List[str]=0.0     ,  _A    :				int=0.02     ,  _A    :				Optional[Any]=2     ,  _A    :				Tuple=True     ,  _A    :				Dict=1     ,  _A    :				Optional[Any]=0     ,  _A    :				Optional[int]=2     ,  _A    :				Union[str, Any]=10_24     ,  **_A    :				Any     ,  )   ->     int:
					__snake_case      :							Union[str, Any]						=			vocab_size
					__snake_case      :							int						=			d_model
					__snake_case      :							Optional[Any]						=			decoder_ffn_dim
					__snake_case      :							str						=			decoder_layers
					__snake_case      :							Tuple						=			decoder_attention_heads
					__snake_case      :							Dict						=			dropout
					__snake_case      :							Tuple						=			attention_dropout
					__snake_case      :							List[str]						=			activation_dropout
					__snake_case      :							str						=			activation_function
					__snake_case      :							Union[str, Any]						=			init_std
					__snake_case      :							str						=			decoder_layerdrop
					__snake_case      :							str						=			use_cache
					__snake_case      :							str						=			decoder_layers
					__snake_case      :							Any						=			scale_embedding  # scale factor will be sqrt(d_model) if True
					__snake_case      :							str						=			max_target_positions

					super().__init__(
					    pad_token_id=_A     ,  bos_token_id=_A     ,  eos_token_id=_A     ,  decoder_start_token_id=_A     ,  **_A     ,  )






"""simple docstring"""







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

	'''simple docstring'''





	__snake_case      :							Optional[int]						=			iter(UpperCAmelCase_  )
	while True:
		__snake_case      :							Optional[int]						=			tuple(itertools.islice(UpperCAmelCase_      ,							UpperCAmelCase_  )  )
		if not chunk:
			return
		yield chunk
def   __UpperCAmelCase    (   UpperCAmelCase_   :    str  )							->      str:

	'''simple docstring'''





	__snake_case      :							Any						=			''.join([c.upper() for c in dirty if c in string.ascii_letters]  )
	__snake_case      :							Union[str, 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   __UpperCAmelCase    (   UpperCAmelCase_   :    str  )							->      list[str]:

	'''simple docstring'''





	__snake_case      :							List[str]						=			'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
	__snake_case      :							Optional[int]						=			[]

	# 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   __UpperCAmelCase    (   UpperCAmelCase_   :    str      ,							UpperCAmelCase_   :    str  )							->      str:

	'''simple docstring'''





	__snake_case      :							str						=			generate_table(UpperCAmelCase_  )
	__snake_case      :							Union[str, Any]						=			prepare_input(UpperCAmelCase_  )
	__snake_case      :							Tuple						=			''

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

	'''simple docstring'''





	__snake_case      :							Optional[int]						=			generate_table(UpperCAmelCase_  )
	__snake_case      :							Any						=			''

	# https://en.wikipedia.org/wiki/Playfair_cipher#Description
	for chara, chara in chunker(UpperCAmelCase_      ,							2  ):
		__snake_case		,    __snake_case      :							Union[str, Any]						=			divmod(table.index(UpperCAmelCase_  )      ,							5  )
		__snake_case		,    __snake_case      :							Tuple						=			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





