




"""simple docstring"""




from string import ascii_uppercase

lowerCAmelCase				:     List[Any]					=				{char: i for i, char in enumerate(ascii_uppercase)}
lowerCAmelCase				:     int					=				dict(enumerate(ascii_uppercase))



def        a__					(							snake_case__			,					snake_case__							)		->   str:
			lowerCamelCase      =   len(snake_case__							)
			lowerCamelCase      =   0
			while True:
						if x == i:
									lowerCamelCase      =   0
						if len(snake_case__							) == len(snake_case__							):
									break
						key += key[i]
						i += 1
			return key



def        a__					(							snake_case__			,					snake_case__							)		->   str:
			lowerCamelCase      =   """"""
			lowerCamelCase      =   0
			for letter in message:
						if letter == " ":
									cipher_text += " "
						else:
									lowerCamelCase      =   (dicta[letter] - dicta[key_new[i]]) % 26
									i += 1
									cipher_text += dicta[x]
			return cipher_text



def        a__					(							snake_case__			,					snake_case__							)		->   str:
			lowerCamelCase      =   """"""
			lowerCamelCase      =   0
			for letter in cipher_text:
						if letter == " ":
									or_txt += " "
						else:
									lowerCamelCase      =   (dicta[letter] + dicta[key_new[i]] + 26) % 26
									i += 1
									or_txt += dicta[x]
			return or_txt



def        a__					(							)		->   None:
			lowerCamelCase      =   """THE GERMAN ATTACK"""
			lowerCamelCase      =   """SECRET"""
			lowerCamelCase      =   generate_key(snake_case__			,					snake_case__							)
			lowerCamelCase      =   cipher_text(snake_case__			,					snake_case__							)
			print(F'Encrypted Text = {s}'							)
			print(F'Original Text = {original_text(snake_case__			,					snake_case__							)}'							)


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					main()









"""simple docstring"""




import re

from flax.core.frozen_dict import freeze
from flax.traverse_util import flatten_dict, unflatten_dict
from jax.experimental import PartitionSpec as P


# Sentinels
lowerCAmelCase				:     List[str]					=				object()

# For specifying empty leaf dict `{}`
lowerCAmelCase				:     Any					=				object()



def        a__					(							snake_case__			,					snake_case__							)		->   List[Any]:
			lowerCamelCase      =   tuple((re.compile(x + """$"""							) for x in qs)							)
			for i in range(len(snake_case__							) - len(snake_case__							) + 1							):
						lowerCamelCase      =   [x.match(snake_case__							) for x, y in zip(snake_case__			,					ks[i:]							)]
						if matches and all(snake_case__							):
									return True
			return False



def        a__					(							snake_case__							)		->   str:
			def replace(snake_case__			,					snake_case__							):
						for rule, replacement in rules:
									if _match(snake_case__			,					snake_case__							):
												return replacement
						return val

			return replace



def        a__					(							)		->   Union[str, Any]:
			return [
			    # embeddings
			    (("transformer", "wpe", "embedding"), P("""mp"""			,					snake_case__							)),
			    (("transformer", "wte", "embedding"), P("""mp"""			,					snake_case__							)),
			    # atention
			    (("attention", "(q_proj|k_proj|v_proj)", "kernel"), P(snake_case__			,					"""mp"""							)),
			    (("attention", "out_proj", "kernel"), P("""mp"""			,					snake_case__							)),
			    (("attention", "out_proj", "bias"), None),
			    # mlp
			    (("mlp", "c_fc", "kernel"), P(snake_case__			,					"""mp"""							)),
			    (("mlp", "c_fc", "bias"), P("""mp"""							)),
			    (("mlp", "c_proj", "kernel"), P("""mp"""			,					snake_case__							)),
			    (("mlp", "c_proj", "bias"), None),
			    # layer norms
			    ((r"ln_\d+", "bias"), None),
			    ((r"\d+", r"ln_\d+", "scale"), None),
			    (("ln_f", "bias"), None),
			    (("ln_f", "scale"), None),
			]



def        a__					(							snake_case__							)		->   Optional[Any]:
			lowerCamelCase      =   _get_partition_rules()
			lowerCamelCase      =   _replacement_rules(snake_case__							)
			lowerCamelCase      =   {k: _unmatched for k in flatten_dict(snake_case__							)}
			lowerCamelCase      =   {k: replace(snake_case__			,					snake_case__							) for k, v in initd.items()}
			assert _unmatched not in result.values(), "Incomplete partition spec."
			return freeze(unflatten_dict(snake_case__							)							)



