
"""simple docstring"""

import os
import tempfile
import unittest
from pathlib import Path

from transformers import AutoConfig, is_torch_available
from transformers.testing_utils import require_torch, torch_device


if is_torch_available():
					from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments






@require_torch
class 	_lowercase       (    unittest.TestCase		):




	def       _UpperCamelCase   (			self		,			UpperCAmelCase_ )		->							int:
		for model_result in results.values():
			for batch_size, sequence_length in zip(model_result['bs']		,			model_result['ss'] ):
				lowerCamelCase					:      List[Any]          =   model_result['''result'''][batch_size][sequence_length]
				self.assertIsNotNone(lowercase_ )




	def       _UpperCamelCase   (			self )		->							int:
		lowerCamelCase					:      int          =   '''sshleifer/tiny-gpt2'''
		lowerCamelCase					:      str          =   PyTorchBenchmarkArguments(
		    models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
		lowerCamelCase					:      Dict          =   PyTorchBenchmark(lowercase_ )
		lowerCamelCase					:      int          =   benchmark.run()
		self.check_results_dict_not_empty(results.time_inference_result )
		self.check_results_dict_not_empty(results.memory_inference_result )




	def       _UpperCamelCase   (			self )		->							Dict:
		lowerCamelCase					:      Tuple          =   '''sgugger/tiny-distilbert-classification'''
		lowerCamelCase					:      List[str]          =   PyTorchBenchmarkArguments(
		    models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			only_pretrain_model=lowercase_		,			)
		lowerCamelCase					:      List[Any]          =   PyTorchBenchmark(lowercase_ )
		lowerCamelCase					:      Optional[int]          =   benchmark.run()
		self.check_results_dict_not_empty(results.time_inference_result )
		self.check_results_dict_not_empty(results.memory_inference_result )




	def       _UpperCamelCase   (			self )		->							List[Any]:
		lowerCamelCase					:      List[str]          =   '''sshleifer/tiny-gpt2'''
		lowerCamelCase					:      str          =   PyTorchBenchmarkArguments(
		    models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			torchscript=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
		lowerCamelCase					:      Dict          =   PyTorchBenchmark(lowercase_ )
		lowerCamelCase					:      Dict          =   benchmark.run()
		self.check_results_dict_not_empty(results.time_inference_result )
		self.check_results_dict_not_empty(results.memory_inference_result )




	@unittest.skipIf(torch_device == 'cpu'		,			'Cant do half precision' )
	def       _UpperCamelCase   (			self )		->							Optional[Any]:
		lowerCamelCase					:      List[str]          =   '''sshleifer/tiny-gpt2'''
		lowerCamelCase					:      List[str]          =   PyTorchBenchmarkArguments(
		    models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			fpaa=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
		lowerCamelCase					:      List[Any]          =   PyTorchBenchmark(lowercase_ )
		lowerCamelCase					:      List[str]          =   benchmark.run()
		self.check_results_dict_not_empty(results.time_inference_result )
		self.check_results_dict_not_empty(results.memory_inference_result )




	def       _UpperCamelCase   (			self )		->							Any:
		lowerCamelCase					:      Union[str, Any]          =   '''sshleifer/tiny-gpt2'''
		lowerCamelCase					:      Tuple          =   AutoConfig.from_pretrained(lowercase_ )
		# set architectures equal to `None`
		lowerCamelCase					:      Union[str, Any]          =   None
		lowerCamelCase					:      Optional[int]          =   PyTorchBenchmarkArguments(
		    models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
		lowerCamelCase					:      List[str]          =   PyTorchBenchmark(lowercase_		,			configs=[config] )
		lowerCamelCase					:      Any          =   benchmark.run()
		self.check_results_dict_not_empty(results.time_inference_result )
		self.check_results_dict_not_empty(results.memory_inference_result )




	def       _UpperCamelCase   (			self )		->							Tuple:
		lowerCamelCase					:      Any          =   '''sshleifer/tiny-gpt2'''
		lowerCamelCase					:      Optional[int]          =   PyTorchBenchmarkArguments(
		    models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
		lowerCamelCase					:      Union[str, Any]          =   PyTorchBenchmark(lowercase_ )
		lowerCamelCase					:      Any          =   benchmark.run()
		self.check_results_dict_not_empty(results.time_train_result )
		self.check_results_dict_not_empty(results.memory_train_result )




	@unittest.skipIf(torch_device == 'cpu'		,			'Can\'t do half precision' )
	def       _UpperCamelCase   (			self )		->							Dict:
		lowerCamelCase					:      Tuple          =   '''sshleifer/tiny-gpt2'''
		lowerCamelCase					:      int          =   PyTorchBenchmarkArguments(
		    models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			fpaa=lowercase_		,			multi_process=lowercase_		,			)
		lowerCamelCase					:      int          =   PyTorchBenchmark(lowercase_ )
		lowerCamelCase					:      Union[str, Any]          =   benchmark.run()
		self.check_results_dict_not_empty(results.time_train_result )
		self.check_results_dict_not_empty(results.memory_train_result )




	def       _UpperCamelCase   (			self )		->							Tuple:
		lowerCamelCase					:      Union[str, Any]          =   '''sshleifer/tiny-gpt2'''
		lowerCamelCase					:      List[str]          =   AutoConfig.from_pretrained(lowercase_ )
		lowerCamelCase					:      List[Any]          =   PyTorchBenchmarkArguments(
		    models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
		lowerCamelCase					:      str          =   PyTorchBenchmark(lowercase_		,			configs=[config] )
		lowerCamelCase					:      Union[str, Any]          =   benchmark.run()
		self.check_results_dict_not_empty(results.time_inference_result )
		self.check_results_dict_not_empty(results.memory_inference_result )




	def       _UpperCamelCase   (			self )		->							Any:
		lowerCamelCase					:      Any          =   '''sshleifer/tinier_bart'''
		lowerCamelCase					:      List[Any]          =   AutoConfig.from_pretrained(lowercase_ )
		lowerCamelCase					:      Optional[int]          =   PyTorchBenchmarkArguments(
		    models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
		lowerCamelCase					:      Dict          =   PyTorchBenchmark(lowercase_		,			configs=[config] )
		lowerCamelCase					:      Dict          =   benchmark.run()
		self.check_results_dict_not_empty(results.time_inference_result )
		self.check_results_dict_not_empty(results.memory_inference_result )




	def       _UpperCamelCase   (			self )		->							Union[str, Any]:
		lowerCamelCase					:      Union[str, Any]          =   '''sshleifer/tiny-gpt2'''
		lowerCamelCase					:      Union[str, Any]          =   AutoConfig.from_pretrained(lowercase_ )
		lowerCamelCase					:      int          =   PyTorchBenchmarkArguments(
		    models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
		lowerCamelCase					:      Any          =   PyTorchBenchmark(lowercase_		,			configs=[config] )
		lowerCamelCase					:      List[Any]          =   benchmark.run()
		self.check_results_dict_not_empty(results.time_train_result )
		self.check_results_dict_not_empty(results.memory_train_result )




	def       _UpperCamelCase   (			self )		->							Tuple:
		lowerCamelCase					:      int          =   '''sshleifer/tinier_bart'''
		lowerCamelCase					:      Dict          =   AutoConfig.from_pretrained(lowercase_ )
		lowerCamelCase					:      int          =   PyTorchBenchmarkArguments(
		    models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			multi_process=lowercase_		,			)
		lowerCamelCase					:      Optional[int]          =   PyTorchBenchmark(lowercase_		,			configs=[config] )
		lowerCamelCase					:      Optional[Any]          =   benchmark.run()
		self.check_results_dict_not_empty(results.time_train_result )
		self.check_results_dict_not_empty(results.memory_train_result )




	def       _UpperCamelCase   (			self )		->							int:
		lowerCamelCase					:      str          =   '''sshleifer/tiny-gpt2'''
		with tempfile.TemporaryDirectory() as tmp_dir:
			lowerCamelCase					:      int          =   PyTorchBenchmarkArguments(
			    models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			save_to_csv=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			inference_time_csv_file=os.path.join(lowercase_		,			'inf_time.csv' )		,			train_memory_csv_file=os.path.join(lowercase_		,			'train_mem.csv' )		,			inference_memory_csv_file=os.path.join(lowercase_		,			'inf_mem.csv' )		,			train_time_csv_file=os.path.join(lowercase_		,			'train_time.csv' )		,			env_info_csv_file=os.path.join(lowercase_		,			'env.csv' )		,			multi_process=lowercase_		,			)
			lowerCamelCase					:      Dict          =   PyTorchBenchmark(lowercase_ )
			benchmark.run()
			self.assertTrue(Path(os.path.join(lowercase_		,			'inf_time.csv' ) ).exists() )
			self.assertTrue(Path(os.path.join(lowercase_		,			'train_time.csv' ) ).exists() )
			self.assertTrue(Path(os.path.join(lowercase_		,			'inf_mem.csv' ) ).exists() )
			self.assertTrue(Path(os.path.join(lowercase_		,			'train_mem.csv' ) ).exists() )
			self.assertTrue(Path(os.path.join(lowercase_		,			'env.csv' ) ).exists() )




	def       _UpperCamelCase   (			self )		->							List[Any]:
		lowerCamelCase					:      int          =   '''sshleifer/tiny-gpt2'''

		def _check_summary_is_not_empty(UpperCAmelCase_ ):
			self.assertTrue(hasattr(lowercase_		,			'sequential' ) )
			self.assertTrue(hasattr(lowercase_		,			'cumulative' ) )
			self.assertTrue(hasattr(lowercase_		,			'current' ) )
			self.assertTrue(hasattr(lowercase_		,			'total' ) )

		with tempfile.TemporaryDirectory() as tmp_dir:
			lowerCamelCase					:      Union[str, Any]          =   PyTorchBenchmarkArguments(
			    models=[MODEL_ID]		,			training=lowercase_		,			inference=lowercase_		,			sequence_lengths=[8]		,			batch_sizes=[1]		,			log_filename=os.path.join(lowercase_		,			'log.txt' )		,			log_print=lowercase_		,			trace_memory_line_by_line=lowercase_		,			multi_process=lowercase_		,			)
			lowerCamelCase					:      Tuple          =   PyTorchBenchmark(lowercase_ )
			lowerCamelCase					:      Optional[Any]          =   benchmark.run()
			_check_summary_is_not_empty(result.inference_summary )
			_check_summary_is_not_empty(result.train_summary )
			self.assertTrue(Path(os.path.join(lowercase_		,			'log.txt' ) ).exists() )








"""simple docstring"""

def 		UpperCAmelCase (		a_      ):





		'''simple docstring'''


		lowerCamelCase					:      List[Any]          =   1
		for i in range(1,						num + 1      ):
				fact *= i
		return fact
def 		UpperCAmelCase (		a_      ):





		'''simple docstring'''


		lowerCamelCase					:      Optional[Any]          =   0
		while number > 0:
				lowerCamelCase					:      str          =   number % 10
				sum_of_digits += last_digit
				lowerCamelCase					:      Tuple          =   number // 10  # Removing the last_digit from the given number
		return sum_of_digits
def 		UpperCAmelCase (		a_ = 100      ):





		'''simple docstring'''


		lowerCamelCase					:      Optional[Any]          =   factorial(a_      )
		lowerCamelCase					:      int          =   split_and_add(a_      )
		return result


if __name__ == "__main__":
					print(solution(int(input('Enter the Number: ').strip())))






