



import doctest
import logging
import os
import unittest
from pathlib import Path
from typing import List, Union

import transformers
from transformers.testing_utils import require_tf, require_torch, slow


snake_case    :						List[Any]  =						logging.getLogger()




@unittest.skip('Temporarily disable the doc tests.'						)
@require_torch
@require_tf
@slow
class 							lowerCAmelCase__  (	unittest.TestCase						):







					def  _lowercase			(       self      :     str			,		_A      :     Path			,		_A      :     Union[str, None] = None			,		_A      :     Union[List[str], None] = None			,		_A      :     Union[str, List[str], None] = None			,		_A      :     bool = True			,		):
											A__	:							List[str]						    = [file for file in os.listdir(_A) if os.path.isfile(os.path.join(_A			,		_A))]

											if identifier is not None:
																	A__	:							Optional[Any]						    = [file for file in files if identifier in file]

											if n_identifier is not None:
																	if isinstance(_A			,		_A):
																							for n_ in n_identifier:
																													A__	:							str						    = [file for file in files if n_ not in file]
																	else:
																							A__	:							Optional[Any]						    = [file for file in files if n_identifier not in file]

											A__	:							Optional[int]						    = ignore_files or []
											ignore_files.append("__init__.py")
											A__	:							List[str]						    = [file for file in files if file not in ignore_files]

											for file in files:
																	# Open all files
																	print("Testing"			,		_A)

																	if only_modules:
																							A__	:							str						    = file.split(".")[0]
																							try:
																													A__	:							Optional[Any]						    = getattr(_A			,		_A)
																													A__	:							Tuple						    = doctest.DocTestSuite(_A)
																													A__	:							Optional[int]						    = unittest.TextTestRunner().run(_A)
																													self.assertIs(len(result.failures)			,		0)
																							except AttributeError:
																													logger.info(F'{module_identifier} is not a module.')
																	else:
																							A__	:							str						    = doctest.testfile(str(".." / directory / file)			,		optionflags=doctest.ELLIPSIS)
																							self.assertIs(result.failed			,		0)







					def  _lowercase			(       self      :     Optional[int]):
											A__	:							Optional[Any]						    = Path("src/transformers")
											A__	:							int						    = "modeling"
											A__	:							Optional[int]						    = [
											    "modeling_ctrl.py",
											    "modeling_tf_ctrl.py",
											]
											self.analyze_directory(_A			,		identifier=_A			,		ignore_files=_A)







					def  _lowercase			(       self      :     List[str]):
											A__	:							Optional[int]						    = Path("src/transformers")
											A__	:							Any						    = "tokenization"
											self.analyze_directory(_A			,		identifier=_A)







					def  _lowercase			(       self      :     List[Any]):
											A__	:							List[str]						    = Path("src/transformers")
											A__	:							List[str]						    = "configuration"
											self.analyze_directory(_A			,		identifier=_A)







					def  _lowercase			(       self      :     str):
											A__	:							int						    = Path("src/transformers")
											A__	:							int						    = ["configuration", "modeling", "tokenization"]
											self.analyze_directory(_A			,		n_identifier=_A)







					def  _lowercase			(       self      :     Any):
											A__	:							Optional[Any]						    = Path("docs/source")
											A__	:							Dict						    = ["favicon.ico"]
											self.analyze_directory(_A			,		ignore_files=_A			,		only_modules=_A)




snake_case    :						Tuple  =						'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def 	snake_case__       (					)		->		None:







						"""simple docstring"""

						A__	:							Union[str, Any]						    = input("Enter message: "       )
						A__	:							Tuple						    = input("Enter key [alphanumeric]: "       )
						A__	:							Optional[Any]						    = input("Encrypt/Decrypt [e/d]: "       )

						if mode.lower().startswith("e"       ):
												A__	:							Tuple						    = "encrypt"
												A__	:							str						    = encrypt_message(__lowercase							,     __lowercase       )
						elif mode.lower().startswith("d"       ):
												A__	:							Optional[Any]						    = "decrypt"
												A__	:							Union[str, Any]						    = decrypt_message(__lowercase							,     __lowercase       )

						print(F'\n{mode.title()}ed message:'       )
						print(__lowercase       )
def 	snake_case__       (					__lowercase							,     __lowercase       )		->		str:







						"""simple docstring"""

						return translate_message(__lowercase							,     __lowercase							,     "encrypt"       )
def 	snake_case__       (					__lowercase							,     __lowercase       )		->		str:







						"""simple docstring"""

						return translate_message(__lowercase							,     __lowercase							,     "decrypt"       )
def 	snake_case__       (					__lowercase							,     __lowercase							,     __lowercase       )		->		str:







						"""simple docstring"""

						A__	:							Dict						    = []
						A__	:							Union[str, Any]						    = 0
						A__	:							List[Any]						    = key.upper()

						for symbol in message:
												A__	:							List[str]						    = LETTERS.find(symbol.upper()       )
												if num != -1:
																		if mode == "encrypt":
																								num += LETTERS.find(key[key_index]       )
																		elif mode == "decrypt":
																								num -= LETTERS.find(key[key_index]       )

																		num %= len(__lowercase       )

																		if symbol.isupper():
																								translated.append(LETTERS[num]       )
																		elif symbol.islower():
																								translated.append(LETTERS[num].lower()       )

																		key_index += 1
																		if key_index == len(__lowercase       ):
																								A__	:							Optional[int]						    = 0
												else:
																		translated.append(__lowercase       )
						return "".join(__lowercase       )


if __name__ == "__main__":
		main()