





"""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							):







					'''simple docstring'''




					def  _lowerCamelCase		(						self	,			_UpperCAmelCase     ):
									for model_result in results.values():
													for batch_size, sequence_length in zip(model_result['''bs''']	,			model_result['''ss''']     ):
																	__a :						List[str]			       =  model_result['''result'''][batch_size][sequence_length]
																	self.assertIsNotNone(_UpperCAmelCase     )







					def  _lowerCamelCase		(						self     ):
									__a :						Optional[int]			       =  '''sshleifer/tiny-gpt2'''
									__a :						List[Any]			       =  PyTorchBenchmarkArguments(
									    models=[MODEL_ID]	,			training=_UpperCAmelCase	,			inference=_UpperCAmelCase	,			sequence_lengths=[8]	,			batch_sizes=[1]	,			multi_process=_UpperCAmelCase	,			)
									__a :						Union[str, Any]			       =  PyTorchBenchmark(_UpperCAmelCase     )
									__a :						str			       =  benchmark.run()
									self.check_results_dict_not_empty(results.time_inference_result     )
									self.check_results_dict_not_empty(results.memory_inference_result     )







					def  _lowerCamelCase		(						self     ):
									__a :						List[Any]			       =  '''sgugger/tiny-distilbert-classification'''
									__a :						List[Any]			       =  PyTorchBenchmarkArguments(
									    models=[MODEL_ID]	,			training=_UpperCAmelCase	,			inference=_UpperCAmelCase	,			sequence_lengths=[8]	,			batch_sizes=[1]	,			multi_process=_UpperCAmelCase	,			only_pretrain_model=_UpperCAmelCase	,			)
									__a :						Dict			       =  PyTorchBenchmark(_UpperCAmelCase     )
									__a :						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  _lowerCamelCase		(						self     ):
									__a :						Any			       =  '''sshleifer/tiny-gpt2'''
									__a :						Union[str, Any]			       =  PyTorchBenchmarkArguments(
									    models=[MODEL_ID]	,			training=_UpperCAmelCase	,			inference=_UpperCAmelCase	,			torchscript=_UpperCAmelCase	,			sequence_lengths=[8]	,			batch_sizes=[1]	,			multi_process=_UpperCAmelCase	,			)
									__a :						Any			       =  PyTorchBenchmark(_UpperCAmelCase     )
									__a :						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     )







					@unittest.skipIf(torch_device == '''cpu'''	,			'''Cant do half precision'''     )
					def  _lowerCamelCase		(						self     ):
									__a :						str			       =  '''sshleifer/tiny-gpt2'''
									__a :						Dict			       =  PyTorchBenchmarkArguments(
									    models=[MODEL_ID]	,			training=_UpperCAmelCase	,			inference=_UpperCAmelCase	,			fpaa=_UpperCAmelCase	,			sequence_lengths=[8]	,			batch_sizes=[1]	,			multi_process=_UpperCAmelCase	,			)
									__a :						int			       =  PyTorchBenchmark(_UpperCAmelCase     )
									__a :						Tuple			       =  benchmark.run()
									self.check_results_dict_not_empty(results.time_inference_result     )
									self.check_results_dict_not_empty(results.memory_inference_result     )







					def  _lowerCamelCase		(						self     ):
									__a :						Optional[Any]			       =  '''sshleifer/tiny-gpt2'''
									__a :						Optional[Any]			       =  AutoConfig.from_pretrained(_UpperCAmelCase     )
									# set architectures equal to `None`
									__a :						Tuple			       =  None
									__a :						Optional[Any]			       =  PyTorchBenchmarkArguments(
									    models=[MODEL_ID]	,			training=_UpperCAmelCase	,			inference=_UpperCAmelCase	,			sequence_lengths=[8]	,			batch_sizes=[1]	,			multi_process=_UpperCAmelCase	,			)
									__a :						str			       =  PyTorchBenchmark(_UpperCAmelCase	,			configs=[config]     )
									__a :						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  _lowerCamelCase		(						self     ):
									__a :						List[Any]			       =  '''sshleifer/tiny-gpt2'''
									__a :						Any			       =  PyTorchBenchmarkArguments(
									    models=[MODEL_ID]	,			training=_UpperCAmelCase	,			inference=_UpperCAmelCase	,			sequence_lengths=[8]	,			batch_sizes=[1]	,			multi_process=_UpperCAmelCase	,			)
									__a :						Any			       =  PyTorchBenchmark(_UpperCAmelCase     )
									__a :						List[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  _lowerCamelCase		(						self     ):
									__a :						Union[str, Any]			       =  '''sshleifer/tiny-gpt2'''
									__a :						Any			       =  PyTorchBenchmarkArguments(
									    models=[MODEL_ID]	,			training=_UpperCAmelCase	,			inference=_UpperCAmelCase	,			sequence_lengths=[8]	,			batch_sizes=[1]	,			fpaa=_UpperCAmelCase	,			multi_process=_UpperCAmelCase	,			)
									__a :						Dict			       =  PyTorchBenchmark(_UpperCAmelCase     )
									__a :						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  _lowerCamelCase		(						self     ):
									__a :						Tuple			       =  '''sshleifer/tiny-gpt2'''
									__a :						Optional[int]			       =  AutoConfig.from_pretrained(_UpperCAmelCase     )
									__a :						Optional[Any]			       =  PyTorchBenchmarkArguments(
									    models=[MODEL_ID]	,			training=_UpperCAmelCase	,			inference=_UpperCAmelCase	,			sequence_lengths=[8]	,			batch_sizes=[1]	,			multi_process=_UpperCAmelCase	,			)
									__a :						str			       =  PyTorchBenchmark(_UpperCAmelCase	,			configs=[config]     )
									__a :						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  _lowerCamelCase		(						self     ):
									__a :						Any			       =  '''sshleifer/tinier_bart'''
									__a :						Union[str, Any]			       =  AutoConfig.from_pretrained(_UpperCAmelCase     )
									__a :						List[str]			       =  PyTorchBenchmarkArguments(
									    models=[MODEL_ID]	,			training=_UpperCAmelCase	,			inference=_UpperCAmelCase	,			sequence_lengths=[8]	,			batch_sizes=[1]	,			multi_process=_UpperCAmelCase	,			)
									__a :						Dict			       =  PyTorchBenchmark(_UpperCAmelCase	,			configs=[config]     )
									__a :						Optional[Any]			       =  benchmark.run()
									self.check_results_dict_not_empty(results.time_inference_result     )
									self.check_results_dict_not_empty(results.memory_inference_result     )







					def  _lowerCamelCase		(						self     ):
									__a :						Optional[Any]			       =  '''sshleifer/tiny-gpt2'''
									__a :						Optional[Any]			       =  AutoConfig.from_pretrained(_UpperCAmelCase     )
									__a :						str			       =  PyTorchBenchmarkArguments(
									    models=[MODEL_ID]	,			training=_UpperCAmelCase	,			inference=_UpperCAmelCase	,			sequence_lengths=[8]	,			batch_sizes=[1]	,			multi_process=_UpperCAmelCase	,			)
									__a :						List[str]			       =  PyTorchBenchmark(_UpperCAmelCase	,			configs=[config]     )
									__a :						Tuple			       =  benchmark.run()
									self.check_results_dict_not_empty(results.time_train_result     )
									self.check_results_dict_not_empty(results.memory_train_result     )







					def  _lowerCamelCase		(						self     ):
									__a :						Dict			       =  '''sshleifer/tinier_bart'''
									__a :						Union[str, Any]			       =  AutoConfig.from_pretrained(_UpperCAmelCase     )
									__a :						Any			       =  PyTorchBenchmarkArguments(
									    models=[MODEL_ID]	,			training=_UpperCAmelCase	,			inference=_UpperCAmelCase	,			sequence_lengths=[8]	,			batch_sizes=[1]	,			multi_process=_UpperCAmelCase	,			)
									__a :						Optional[Any]			       =  PyTorchBenchmark(_UpperCAmelCase	,			configs=[config]     )
									__a :						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  _lowerCamelCase		(						self     ):
									__a :						Union[str, Any]			       =  '''sshleifer/tiny-gpt2'''
									with tempfile.TemporaryDirectory() as tmp_dir:
													__a :						Optional[int]			       =  PyTorchBenchmarkArguments(
													    models=[MODEL_ID]	,			training=_UpperCAmelCase	,			inference=_UpperCAmelCase	,			save_to_csv=_UpperCAmelCase	,			sequence_lengths=[8]	,			batch_sizes=[1]	,			inference_time_csv_file=os.path.join(_UpperCAmelCase	,			'''inf_time.csv'''     )	,			train_memory_csv_file=os.path.join(_UpperCAmelCase	,			'''train_mem.csv'''     )	,			inference_memory_csv_file=os.path.join(_UpperCAmelCase	,			'''inf_mem.csv'''     )	,			train_time_csv_file=os.path.join(_UpperCAmelCase	,			'''train_time.csv'''     )	,			env_info_csv_file=os.path.join(_UpperCAmelCase	,			'''env.csv'''     )	,			multi_process=_UpperCAmelCase	,			)
													__a :						List[str]			       =  PyTorchBenchmark(_UpperCAmelCase     )
													benchmark.run()
													self.assertTrue(Path(os.path.join(_UpperCAmelCase	,			'''inf_time.csv'''     )     ).exists()     )
													self.assertTrue(Path(os.path.join(_UpperCAmelCase	,			'''train_time.csv'''     )     ).exists()     )
													self.assertTrue(Path(os.path.join(_UpperCAmelCase	,			'''inf_mem.csv'''     )     ).exists()     )
													self.assertTrue(Path(os.path.join(_UpperCAmelCase	,			'''train_mem.csv'''     )     ).exists()     )
													self.assertTrue(Path(os.path.join(_UpperCAmelCase	,			'''env.csv'''     )     ).exists()     )







					def  _lowerCamelCase		(						self     ):
									__a :						Union[str, Any]			       =  '''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:
													__a :						int			       =  PyTorchBenchmarkArguments(
													    models=[MODEL_ID]	,			training=_UpperCAmelCase	,			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	,			multi_process=_UpperCAmelCase	,			)
													__a :						Optional[Any]			       =  PyTorchBenchmark(_UpperCAmelCase     )
													__a :						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(_UpperCAmelCase	,			'''log.txt'''     )     ).exists()     )






"""simple docstring"""






from math import isqrt, loga

def     __A      (			a_						:int)		->		list[int]:
				__a :						int			       =  [True] * max_number
				for i in range(2   ,       isqrt(max_number - 1) + 1):
								if is_prime[i]:
												for j in range(i**2   ,       a_   ,       a_):
																__a :						int			       =  False

				return [i for i in range(2   ,       a_) if is_prime[i]]

def     __A      (			a_						:int = 80_08_00   ,       a_						:int = 80_08_00)		->		int:
				__a :						str			       =  degree * loga(a_)
				__a :						Tuple			       =  int(a_)
				__a :						int			       =  calculate_prime_numbers(a_)

				__a :						List[Any]			       =  0
				__a :						Optional[Any]			       =  0
				__a :						Dict			       =  len(a_) - 1
				while left < right:
								while (
								    prime_numbers[right] * loga(prime_numbers[left])
								    + prime_numbers[left] * loga(prime_numbers[right])
								    > upper_bound
								):
												right -= 1
								hybrid_integers_count += right - left
								left += 1

				return hybrid_integers_count


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