






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


__A      =				logging.get_logger(__name__)

__A      =				{"openai-gpt": "https://huggingface.co/openai-gpt/resolve/main/config.json"}





class 						SCREAMING_SNAKE_CASE				( _UpperCAmelCase					):





							"""simple docstring"""

							A_						  =					"openai-gpt"
							A_						  =					{
							    "max_position_embeddings": "n_positions",
							    "hidden_size": "n_embd",
							    "num_attention_heads": "n_head",
							    "num_hidden_layers": "n_layer",
							}

							def __init__(  self:   Optional[int]		,     __A:   str=4_04_78		,     __A:   Optional[Any]=5_12		,     __A:   str=7_68		,     __A:   List[str]=12		,     __A:   Tuple=12		,     __A:   str="gelu"		,     __A:   Union[str, Any]=0.1		,     __A:   str=0.1		,     __A:   Dict=0.1		,     __A:   int=1e-5		,     __A:   List[str]=0.02		,     __A:   Dict="cls_index"		,     __A:   List[Any]=True		,     __A:   int=None		,     __A:   List[str]=True		,     __A:   List[Any]=0.1		,     **__A:   List[Any]		,     )    ->				str:
												_A								= vocab_size
												_A								= n_positions
												_A								= n_embd
												_A								= n_layer
												_A								= n_head
												_A								= afn
												_A								= resid_pdrop
												_A								= embd_pdrop
												_A								= attn_pdrop
												_A								= layer_norm_epsilon
												_A								= initializer_range
												_A								= summary_type
												_A								= summary_use_proj
												_A								= summary_activation
												_A								= summary_first_dropout
												_A								= summary_proj_to_labels
												super().__init__(**lowercase_   )











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




def      __A					(     _lowercase					,			_lowercase ):

					'''simple docstring'''







					_A								= iter(_lowercase )
					while True:
										_A								= tuple(itertools.islice(_lowercase					,			_lowercase ) )
										if not chunk:
															return
										yield chunk




def      __A					(     _lowercase ):

					'''simple docstring'''







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

					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      __A					(     _lowercase ):

					'''simple docstring'''







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

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

					'''simple docstring'''







					_A								= generate_table(_lowercase )
					_A								= prepare_input(_lowercase )
					_A								= ''''''

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

					'''simple docstring'''







					_A								= generate_table(_lowercase )
					_A								= ''''''

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



