
import os
import tempfile
import unittest
from pathlib import Path

from transformers import AutoConfig, is_tf_available
from transformers.testing_utils import require_tf


if is_tf_available():
			import tensorflow as tf

			from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments





@require_tf
class       _lowerCAmelCase   (      unittest.TestCase			):




				def 	__a		(   self							,							_UpperCamelCase	)							-> Optional[int]:
							for model_result in results.values():
										for batch_size, sequence_length in zip(model_result["bs"]							,							model_result["ss"]	):
													lowerCAmelCase_         =      model_result["result"][batch_size][sequence_length]
													self.assertIsNotNone(_UpperCamelCase	)




				def 	__a		(   self	)							-> Dict:
							lowerCAmelCase_         =      "sshleifer/tiny-gpt2"
							lowerCAmelCase_         =      TensorFlowBenchmarkArguments(
							    models=[MODEL_ID]							,							training=_UpperCamelCase							,							inference=_UpperCamelCase							,							sequence_lengths=[8]							,							batch_sizes=[1]							,							eager_mode=_UpperCamelCase							,							multi_process=_UpperCamelCase							,							)
							lowerCAmelCase_         =      TensorFlowBenchmark(_UpperCamelCase	)
							lowerCAmelCase_         =      benchmark.run()
							self.check_results_dict_not_empty(results.time_inference_result	)
							self.check_results_dict_not_empty(results.memory_inference_result	)




				def 	__a		(   self	)							-> List[Any]:
							lowerCAmelCase_         =      "sgugger/tiny-distilbert-classification"
							lowerCAmelCase_         =      TensorFlowBenchmarkArguments(
							    models=[MODEL_ID]							,							training=_UpperCamelCase							,							inference=_UpperCamelCase							,							sequence_lengths=[8]							,							batch_sizes=[1]							,							multi_process=_UpperCamelCase							,							only_pretrain_model=_UpperCamelCase							,							)
							lowerCAmelCase_         =      TensorFlowBenchmark(_UpperCamelCase	)
							lowerCAmelCase_         =      benchmark.run()
							self.check_results_dict_not_empty(results.time_inference_result	)
							self.check_results_dict_not_empty(results.memory_inference_result	)




				def 	__a		(   self	)							-> Optional[int]:
							lowerCAmelCase_         =      "sshleifer/tiny-gpt2"
							lowerCAmelCase_         =      TensorFlowBenchmarkArguments(
							    models=[MODEL_ID]							,							training=_UpperCamelCase							,							inference=_UpperCamelCase							,							sequence_lengths=[8]							,							batch_sizes=[1]							,							multi_process=_UpperCamelCase							,							)
							lowerCAmelCase_         =      TensorFlowBenchmark(_UpperCamelCase	)
							lowerCAmelCase_         =      benchmark.run()
							self.check_results_dict_not_empty(results.time_inference_result	)
							self.check_results_dict_not_empty(results.memory_inference_result	)




				def 	__a		(   self	)							-> Optional[int]:
							lowerCAmelCase_         =      "sshleifer/tiny-gpt2"
							lowerCAmelCase_         =      AutoConfig.from_pretrained(_UpperCamelCase	)
							lowerCAmelCase_         =      TensorFlowBenchmarkArguments(
							    models=[MODEL_ID]							,							training=_UpperCamelCase							,							inference=_UpperCamelCase							,							sequence_lengths=[8]							,							batch_sizes=[1]							,							eager_mode=_UpperCamelCase							,							multi_process=_UpperCamelCase							,							)
							lowerCAmelCase_         =      TensorFlowBenchmark(_UpperCamelCase							,							[config]	)
							lowerCAmelCase_         =      benchmark.run()
							self.check_results_dict_not_empty(results.time_inference_result	)
							self.check_results_dict_not_empty(results.memory_inference_result	)




				def 	__a		(   self	)							-> List[Any]:
							lowerCAmelCase_         =      "sshleifer/tiny-gpt2"
							lowerCAmelCase_         =      AutoConfig.from_pretrained(_UpperCamelCase	)
							lowerCAmelCase_         =      TensorFlowBenchmarkArguments(
							    models=[MODEL_ID]							,							training=_UpperCamelCase							,							inference=_UpperCamelCase							,							sequence_lengths=[8]							,							batch_sizes=[1]							,							multi_process=_UpperCamelCase							,							)
							lowerCAmelCase_         =      TensorFlowBenchmark(_UpperCamelCase							,							[config]	)
							lowerCAmelCase_         =      benchmark.run()
							self.check_results_dict_not_empty(results.time_inference_result	)
							self.check_results_dict_not_empty(results.memory_inference_result	)




				def 	__a		(   self	)							-> str:
							lowerCAmelCase_         =      "sshleifer/tiny-gpt2"
							lowerCAmelCase_         =      TensorFlowBenchmarkArguments(
							    models=[MODEL_ID]							,							training=_UpperCamelCase							,							inference=_UpperCamelCase							,							sequence_lengths=[8]							,							batch_sizes=[1]							,							multi_process=_UpperCamelCase							,							)
							lowerCAmelCase_         =      TensorFlowBenchmark(_UpperCamelCase	)
							lowerCAmelCase_         =      benchmark.run()
							self.check_results_dict_not_empty(results.time_train_result	)
							self.check_results_dict_not_empty(results.memory_train_result	)




				def 	__a		(   self	)							-> Optional[Any]:
							lowerCAmelCase_         =      "sshleifer/tiny-gpt2"
							lowerCAmelCase_         =      AutoConfig.from_pretrained(_UpperCamelCase	)
							lowerCAmelCase_         =      TensorFlowBenchmarkArguments(
							    models=[MODEL_ID]							,							training=_UpperCamelCase							,							inference=_UpperCamelCase							,							sequence_lengths=[8]							,							batch_sizes=[1]							,							multi_process=_UpperCamelCase							,							)
							lowerCAmelCase_         =      TensorFlowBenchmark(_UpperCamelCase							,							[config]	)
							lowerCAmelCase_         =      benchmark.run()
							self.check_results_dict_not_empty(results.time_train_result	)
							self.check_results_dict_not_empty(results.memory_train_result	)




				def 	__a		(   self	)							-> List[Any]:
							lowerCAmelCase_         =      "patrickvonplaten/t5-tiny-random"
							lowerCAmelCase_         =      AutoConfig.from_pretrained(_UpperCamelCase	)
							lowerCAmelCase_         =      TensorFlowBenchmarkArguments(
							    models=[MODEL_ID]							,							training=_UpperCamelCase							,							inference=_UpperCamelCase							,							sequence_lengths=[8]							,							batch_sizes=[1]							,							multi_process=_UpperCamelCase							,							)
							lowerCAmelCase_         =      TensorFlowBenchmark(_UpperCamelCase							,							configs=[config]	)
							lowerCAmelCase_         =      benchmark.run()
							self.check_results_dict_not_empty(results.time_inference_result	)
							self.check_results_dict_not_empty(results.memory_inference_result	)




				@unittest.skipIf(is_tf_available() and len(tf.config.list_physical_devices("GPU"	)	) == 0							,							"Cannot do xla on CPU."	)
				def 	__a		(   self	)							-> Dict:
							lowerCAmelCase_         =      "sshleifer/tiny-gpt2"
							lowerCAmelCase_         =      TensorFlowBenchmarkArguments(
							    models=[MODEL_ID]							,							training=_UpperCamelCase							,							inference=_UpperCamelCase							,							sequence_lengths=[8]							,							batch_sizes=[1]							,							use_xla=_UpperCamelCase							,							multi_process=_UpperCamelCase							,							)
							lowerCAmelCase_         =      TensorFlowBenchmark(_UpperCamelCase	)
							lowerCAmelCase_         =      benchmark.run()
							self.check_results_dict_not_empty(results.time_inference_result	)
							self.check_results_dict_not_empty(results.memory_inference_result	)




				def 	__a		(   self	)							-> List[str]:
							lowerCAmelCase_         =      "sshleifer/tiny-gpt2"
							with tempfile.TemporaryDirectory() as tmp_dir:
										lowerCAmelCase_         =      TensorFlowBenchmarkArguments(
										    models=[MODEL_ID]							,							inference=_UpperCamelCase							,							save_to_csv=_UpperCamelCase							,							sequence_lengths=[8]							,							batch_sizes=[1]							,							inference_time_csv_file=os.path.join(_UpperCamelCase							,							"inf_time.csv"	)							,							inference_memory_csv_file=os.path.join(_UpperCamelCase							,							"inf_mem.csv"	)							,							env_info_csv_file=os.path.join(_UpperCamelCase							,							"env.csv"	)							,							multi_process=_UpperCamelCase							,							)
										lowerCAmelCase_         =      TensorFlowBenchmark(_UpperCamelCase	)
										benchmark.run()
										self.assertTrue(Path(os.path.join(_UpperCamelCase							,							"inf_time.csv"	)	).exists()	)
										self.assertTrue(Path(os.path.join(_UpperCamelCase							,							"inf_mem.csv"	)	).exists()	)
										self.assertTrue(Path(os.path.join(_UpperCamelCase							,							"env.csv"	)	).exists()	)




				def 	__a		(   self	)							-> Tuple:
							lowerCAmelCase_         =      "sshleifer/tiny-gpt2"

							def _check_summary_is_not_empty(_UpperCamelCase	):
										self.assertTrue(hasattr(_UpperCamelCase							,							"sequential"	)	)
										self.assertTrue(hasattr(_UpperCamelCase							,							"cumulative"	)	)
										self.assertTrue(hasattr(_UpperCamelCase							,							"current"	)	)
										self.assertTrue(hasattr(_UpperCamelCase							,							"total"	)	)

							with tempfile.TemporaryDirectory() as tmp_dir:
										lowerCAmelCase_         =      TensorFlowBenchmarkArguments(
										    models=[MODEL_ID]							,							inference=_UpperCamelCase							,							sequence_lengths=[8]							,							batch_sizes=[1]							,							log_filename=os.path.join(_UpperCamelCase							,							"log.txt"	)							,							log_print=_UpperCamelCase							,							trace_memory_line_by_line=_UpperCamelCase							,							eager_mode=_UpperCamelCase							,							multi_process=_UpperCamelCase							,							)
										lowerCAmelCase_         =      TensorFlowBenchmark(_UpperCamelCase	)
										lowerCAmelCase_         =      benchmark.run()
										_check_summary_is_not_empty(result.inference_summary	)
										self.assertTrue(Path(os.path.join(_UpperCamelCase							,							"log.txt"	)	).exists()	)





from functools import reduce

_A  =	(
    "73167176531330624919225119674426574742355349194934"
    "96983520312774506326239578318016984801869478851843"
    "85861560789112949495459501737958331952853208805511"
    "12540698747158523863050715693290963295227443043557"
    "66896648950445244523161731856403098711121722383113"
    "62229893423380308135336276614282806444486645238749"
    "30358907296290491560440772390713810515859307960866"
    "70172427121883998797908792274921901699720888093776"
    "65727333001053367881220235421809751254540594752243"
    "52584907711670556013604839586446706324415722155397"
    "53697817977846174064955149290862569321978468622482"
    "83972241375657056057490261407972968652414535100474"
    "82166370484403199890008895243450658541227588666881"
    "16427171479924442928230863465674813919123162824586"
    "17866458359124566529476545682848912883142607690042"
    "24219022671055626321111109370544217506941658960408"
    "07198403850962455444362981230987879927244284909188"
    "84580156166097919133875499200524063689912560717606"
    "05886116467109405077541002256983155200055935729725"
    "71636269561882670428252483600823257530420752963450"
)






def   lowerCamelCase__							(							__lowerCAmelCase    :    str = N							):




			"""simple docstring"""


			return max(
			    # mypy cannot properly interpret reduce
			    int(reduce(lambda __lowerCAmelCase       ,				__lowerCAmelCase							: str(int(__lowerCAmelCase							) * int(__lowerCAmelCase							)							)       ,				n[i : i + 13]							)							)
			    for i in range(len(__lowerCAmelCase							) - 12							)							)


if __name__ == "__main__":
			print(f"""{solution() = }""")



