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)

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



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			Dict    )						->      Optional[int]:





    """simple docstring"""

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


__a      :       Tuple				  =   logging.StreamHandler(sys.stdout)
logger.addHandler(stream_handler)






@require_torch_tpu
class       __lowercase      (	lowercase__  ):







     '''simple docstring'''




     def 		lowerCAmelCase_     (				self       :			int				):


         """simple docstring"""



         import xla_spawn

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


         """simple docstring"""



         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()












def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			List[Any]			,				__lowercase   :			Dict			,				__lowercase   :			str    )						->      Dict:





    """simple docstring"""

    if n == 0:
        return 1

    elif n % 2 == 1:
        return (binary_exponentiation(__lowercase			,				n - 1			,				__lowercase    ) * a) % mod

    else:
        __A         =	binary_exponentiation(__lowercase			,				n / 2			,				__lowercase    )
        return (b * b) % mod


# a prime number
__a      :       Union[str, Any]				  =   701

__a      :       Dict				  =   1000000000
__a      :       Union[str, Any]				  =   10

# using binary exponentiation function, O(log(p)):
print((a / b) % p == (a * binary_exponentiation(b, p - 2, p)) % p)






print((a / b) % p == (a * b ** (p - 2)) % p)




