


'''simple docstring'''





import json
import logging
import os
import sys
from time import time
from unittest.mock import patch

from transformers.testing_utils import TestCasePlus, require_torch_tpu


logging.basicConfig(level=logging.DEBUG)

UpperCAmelCase__  			=				logging.getLogger()






def 						UpperCAmelCase__(				_SCREAMING_SNAKE_CASE					: Tuple ):






			"""simple docstring"""




			__A=	{}
			__A=	os.path.join(_SCREAMING_SNAKE_CASE,'all_results.json' )
			if os.path.exists(_SCREAMING_SNAKE_CASE ):
						with open(_SCREAMING_SNAKE_CASE,'r' ) as f:
									__A=	json.load(_SCREAMING_SNAKE_CASE )
			else:
						raise ValueError(f"""can't find {path}""" )
			return results


UpperCAmelCase__  			=				logging.StreamHandler(sys.stdout)
logger.addHandler(stream_handler)






@require_torch_tpu
class 						a__					(					a_   ):





			'''simple docstring'''

			def 					lowerCAmelCase     (  self							:			List[Any]	)      ->		Union[str, Any]:
						import xla_spawn

						__A=	self.get_auto_remove_tmp_dir()
						__A=	F"""
            ./examples/pytorch/text-classification/run_glue.py
            --num_cores=8
            ./examples/pytorch/text-classification/run_glue.py
            --model_name_or_path distilbert-base-uncased
            --output_dir {tmp_dir}
            --overwrite_output_dir
            --train_file ./tests/fixtures/tests_samples/MRPC/train.csv
            --validation_file ./tests/fixtures/tests_samples/MRPC/dev.csv
            --do_train
            --do_eval
            --debug tpu_metrics_debug
            --per_device_train_batch_size=2
            --per_device_eval_batch_size=1
            --learning_rate=1e-4
            --max_steps=10
            --warmup_steps=2
            --seed=42
            --max_seq_length=128
            """.split()

						with patch.object(lowerCAmelCase_			,    'argv'			,    lowerCAmelCase_	):
									__A=	time()
									xla_spawn.main()
									__A=	time()

									__A=	get_results(lowerCAmelCase_	)
									self.assertGreaterEqual(result['eval_accuracy']			,    0.75	)

									# Assert that the script takes less than 500 seconds to make sure it doesn't hang.
									self.assertLess(end - start			,    500	)

			def 					lowerCAmelCase     (  self							:			Dict	)      ->		Dict:
						import xla_spawn

						__A=	'\n            ./tests/test_trainer_tpu.py\n            --num_cores=8\n            ./tests/test_trainer_tpu.py\n            '.split()
						with patch.object(lowerCAmelCase_			,    'argv'			,    lowerCAmelCase_	):
									xla_spawn.main()







'''simple docstring'''





import math






def 						UpperCAmelCase__(				_SCREAMING_SNAKE_CASE					: int ):






			"""simple docstring"""




			if not isinstance(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE ):
						__A=	f"""Input value of [number={number}] must be an integer"""
						raise TypeError(_SCREAMING_SNAKE_CASE )

			if number < 1:
						__A=	f"""Input value of [number={number}] must be > 0"""
						raise ValueError(_SCREAMING_SNAKE_CASE )
			elif number == 1:
						return 3
			elif number == 2:
						return 5
			else:
						__A=	int(math.log(number // 3,2 ) ) + 2

						__A=	[3, 5]
						__A=	2
						__A=	3
						for block in range(1,_SCREAMING_SNAKE_CASE ):
									for _ in range(_SCREAMING_SNAKE_CASE ):
												proth_list.append(2 ** (block + 1) + proth_list[proth_index - 1] )
												proth_index += 1
									increment *= 2

			return proth_list[number - 1]


if __name__ == "__main__":
					import doctest

					doctest.testmod()

					for number in range(1_1):
										UpperCAmelCase__  			=				0
										try:
															UpperCAmelCase__  			=				proth(number)
										except ValueError:
															print(F"""ValueError: there is no {number}th Proth number""")
															continue

										print(F"""The {number}th Proth number: {value}""")



