

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

lowerCamelCase					: Dict   					=	logging.getLogger()


def 			_lowerCAmelCase   (		_UpperCamelCase		:	Union[str, Any]							) ->     List[str]:
     """simple docstring"""




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


lowerCamelCase					: List[str]   					=	logging.StreamHandler(sys.stdout)
logger.addHandler(stream_handler)







@require_torch_tpu
class 				A__       (			__snake_case    ):





  def 		A    (						self :      Optional[int]					)      ->       List[Any]:





       '''simple docstring'''






       import xla_spawn

       _SCREAMING_SNAKE_CASE				       =self.get_auto_remove_tmp_dir()
       _SCREAMING_SNAKE_CASE				       =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(A__				,   'argv'				,   A__					):
            _SCREAMING_SNAKE_CASE				       =time()
            xla_spawn.main()
            _SCREAMING_SNAKE_CASE				       =time()

            _SCREAMING_SNAKE_CASE				       =get_results(A__					)
            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 		A    (						self :      str					)      ->       Union[str, Any]:





       '''simple docstring'''






       import xla_spawn

       _SCREAMING_SNAKE_CASE				       ='''
            ./tests/test_trainer_tpu.py
            --num_cores=8
            ./tests/test_trainer_tpu.py
            '''.split()
       with patch.object(A__				,   'argv'				,   A__					):
            xla_spawn.main()








from ...configuration_utils import PretrainedConfig
from ...utils import logging


_UpperCamelCase			:	Optional[int]								=logging.get_logger(__name__)

_UpperCamelCase			:	Tuple								={
    'google/canine-s': 'https://huggingface.co/google/canine-s/resolve/main/config.json',
    # See all CANINE models at https://huggingface.co/models?filter=canine
}






class 						UpperCAmelCase__ (							__snake_case							):
		__snake_case      :       Any     =   "canine"







		def __init__(					self       ,A__=768       ,A__=12       ,A__=12       ,A__=3072       ,A__="gelu"       ,A__=0.1       ,A__=0.1       ,A__=16384       ,A__=16       ,A__=0.02       ,A__=1E-12       ,A__=0       ,A__=0xE_000       ,A__=0xE_001       ,A__=4       ,A__=4       ,A__=8       ,A__=16384       ,A__=128       ,**A__       ,):
						super().__init__(pad_token_id=A__       ,bos_token_id=A__       ,eos_token_id=A__       ,**A__		)

						_A	:				int   =      max_position_embeddings
						_A	:				Dict   =      hidden_size
						_A	:				List[str]   =      num_hidden_layers
						_A	:				Optional[Any]   =      num_attention_heads
						_A	:				Optional[Any]   =      intermediate_size
						_A	:				Optional[Any]   =      hidden_act
						_A	:				str   =      hidden_dropout_prob
						_A	:				Optional[int]   =      attention_probs_dropout_prob
						_A	:				Union[str, Any]   =      initializer_range
						_A	:				Dict   =      type_vocab_size
						_A	:				Optional[Any]   =      layer_norm_eps

						# Character config:
						_A	:				Union[str, Any]   =      downsampling_rate
						_A	:				List[str]   =      upsampling_kernel_size
						_A	:				str   =      num_hash_functions
						_A	:				Optional[Any]   =      num_hash_buckets
						_A	:				Optional[Any]   =      local_transformer_stride



