






'''simple docstring'''





import concurrent.futures
import json
import os
import shutil
import tempfile
import unittest

from transformers import AutoTokenizer, PreTrainedTokenizerFast
from transformers.testing_utils import require_tokenizers

from ..test_tokenization_common import TokenizerTesterMixin
@require_tokenizers
class        __snake_case(					__lowerCamelCase     ,       unittest.TestCase      ):
 lowercase :       int		      =		PreTrainedTokenizerFast
 lowercase :       Dict		      =		False
 lowercase :       Union[str, Any]		      =		True
 lowercase :       int		      =		'''tokenizer_file'''



 def 						UpperCAmelCase    (	self   :   Any	):

    """simple docstring"""






    lowercase__						:	Union[str, Any]         = False  # because we don't have pretrained_vocab_files_map
    super().setUp()
    lowercase__						:	Dict         = True

    lowercase__						:	int         = ["""robot-test/dummy-tokenizer-fast""", """robot-test/dummy-tokenizer-wordlevel"""]
    lowercase__						:	List[Any]         = """SaulLu/dummy-tokenizer-bytelevel-bpe"""

    # Inclusion of 2 tokenizers to test different types of models (Unigram and WordLevel for the moment)
    lowercase__						:	int         = [(PreTrainedTokenizerFast, model_path, {}) for model_path in model_paths]

    lowercase__						:	Union[str, Any]         = PreTrainedTokenizerFast.from_pretrained(model_paths[0]	)
    tokenizer.save_pretrained(self.tmpdirname	)



 def 						UpperCAmelCase    (	self   :   List[Any]	):

    """simple docstring"""






    pass



 def 						UpperCAmelCase    (	self   :   Optional[int]	):

    """simple docstring"""






    pass



 def 						UpperCAmelCase    (	self   :   str	):

    """simple docstring"""






    pass



 def 						UpperCAmelCase    (	self   :   Optional[Any]	):

    """simple docstring"""






    pass



 def 						UpperCAmelCase    (	self   :   str	):

    """simple docstring"""






    lowercase__						:	Optional[int]         = self.tmpdirname
    # Here we want to test the 2 available tokenizers that use 2 different types of models: Unigram and WordLevel.
    for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
       with self.subTest(f'''{tokenizer.__class__.__name__} ({pretrained_name})'''	):
          try:
             lowercase__						:	str         = tempfile.mkdtemp()
             lowercase__						:	Any         = self.rust_tokenizer_class.from_pretrained(_lowerCAmelCase ,		**_lowerCAmelCase	)

             tokenizer.save_pretrained(self.tmpdirname	)
             super().test_training_new_tokenizer()
          finally:
             # Even if the test fails, we must be sure that the folder is deleted and that the default tokenizer
             # is restored
             shutil.rmtree(self.tmpdirname	)
             lowercase__						:	str         = tmpdirname_orig



 def 						UpperCAmelCase    (	self   :   str	):

    """simple docstring"""






    lowercase__						:	Tuple         = self.tmpdirname
    # Here we want to test the 2 available tokenizers that use 2 different types of models: Unigram and WordLevel.
    for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
       with self.subTest(f'''{tokenizer.__class__.__name__} ({pretrained_name})'''	):
          try:
             lowercase__						:	Optional[Any]         = tempfile.mkdtemp()
             lowercase__						:	Any         = self.rust_tokenizer_class.from_pretrained(_lowerCAmelCase ,		**_lowerCAmelCase	)

             tokenizer.save_pretrained(self.tmpdirname	)
             super().test_training_new_tokenizer_with_special_tokens_change()
          finally:
             # Even if the test fails, we must be sure that the folder is deleted and that the default tokenizer
             # is restored
             shutil.rmtree(self.tmpdirname	)
             lowercase__						:	str         = tmpdirname_orig







 def 						UpperCAmelCase    (	self   :   List[str]	):

    """simple docstring"""






    lowercase__						:	Tuple         = self.rust_tokenizer_class.from_pretrained(self.bytelevel_bpe_model_name	)

    lowercase__						:	Dict         = ("""a""" for _ in range(1_000	))
    lowercase__						:	int         = tokenizer.train_new_from_iterator(text_iterator=_lowerCAmelCase ,		length=1_000 ,		vocab_size=50	)

    lowercase__						:	Optional[Any]         = new_tokenizer.encode("""a🤗"""	)
    self.assertEqual(_lowerCAmelCase ,		[64, 172, 253, 97, 245]	)
@require_tokenizers
class        __snake_case(					unittest.TestCase      ):



 def 						UpperCAmelCase    (	self   :   Optional[Any]	):

    """simple docstring"""






    lowercase__						:	List[str]         = AutoTokenizer.from_pretrained("""bert-base-cased"""	)
    lowercase__						:	List[Any]         = json.loads(tokenizer._tokenizer.to_str()	)
    lowercase__						:	Optional[Any]         = len(_lowerCAmelCase	)

    with tempfile.TemporaryDirectory() as tmp_dir:
       # Hack to save this in the tokenizer_config.json
       lowercase__						:	Tuple         = ["""tokenizer.4.0.0.json"""]
       tokenizer.save_pretrained(_lowerCAmelCase	)
       json.dump(_lowerCAmelCase ,		open(os.path.join(_lowerCAmelCase ,		"""tokenizer.4.0.0.json"""	) ,		"""w"""	)	)

       # This should pick the new tokenizer file as the version of Transformers is > 4.0.0
       lowercase__						:	Optional[int]         = AutoTokenizer.from_pretrained(_lowerCAmelCase	)
       self.assertEqual(len(_lowerCAmelCase	) ,		len(_lowerCAmelCase	) + 1	)
       lowercase__						:	Any         = json.loads(new_tokenizer._tokenizer.to_str()	)
       self.assertIn("""huggingface""" ,		json_tokenizer["""model"""]["""vocab"""]	)

       # Will need to be adjusted if we reach v42 and this test is still here.
       # Should pick the old tokenizer file as the version of Transformers is < 4.0.0
       shutil.move(os.path.join(_lowerCAmelCase ,		"""tokenizer.4.0.0.json"""	) ,		os.path.join(_lowerCAmelCase ,		"""tokenizer.42.0.0.json"""	)	)
       lowercase__						:	Union[str, Any]         = ["""tokenizer.42.0.0.json"""]
       tokenizer.save_pretrained(_lowerCAmelCase	)
       lowercase__						:	Optional[Any]         = AutoTokenizer.from_pretrained(_lowerCAmelCase	)
       self.assertEqual(len(_lowerCAmelCase	) ,		len(_lowerCAmelCase	)	)
       lowercase__						:	List[Any]         = json.loads(new_tokenizer._tokenizer.to_str()	)
       self.assertNotIn("""huggingface""" ,		json_tokenizer["""model"""]["""vocab"""]	)







 def 						UpperCAmelCase    (	self   :   List[str]	):

    """simple docstring"""






    lowercase__						:	List[str]         = """hf-internal-testing/test-two-tokenizers"""

    # This should pick the new tokenizer file as the version of Transformers is > 4.0.0
    lowercase__						:	int         = AutoTokenizer.from_pretrained(_lowerCAmelCase	)
    self.assertEqual(len(_lowerCAmelCase	) ,		28_997	)
    lowercase__						:	List[Any]         = json.loads(tokenizer._tokenizer.to_str()	)
    self.assertIn("""huggingface""" ,		json_tokenizer["""model"""]["""vocab"""]	)

    # Testing an older version by monkey-patching the version in the module it's used.
    import transformers as old_transformers

    lowercase__						:	Any         = """3.0.0"""
    lowercase__						:	Optional[int]         = old_transformers.models.auto.AutoTokenizer.from_pretrained(_lowerCAmelCase	)
    self.assertEqual(len(_lowerCAmelCase	) ,		28_996	)
    lowercase__						:	Optional[int]         = json.loads(old_tokenizer._tokenizer.to_str()	)
    self.assertNotIn("""huggingface""" ,		json_tokenizer["""model"""]["""vocab"""]	)
@require_tokenizers
class        __snake_case(					unittest.TestCase      ):



 def 						UpperCAmelCase    (	self   :   Any	):

    """simple docstring"""






    lowercase__						:	int         = PreTrainedTokenizerFast.from_pretrained("""robot-test/dummy-tokenizer-wordlevel"""	)
    lowercase__						:	List[str]         = """The Matrix is a 1999 science fiction action film."""

    with concurrent.futures.ThreadPoolExecutor() as executor:
       lowercase__						:	List[str]         = [executor.submit(self.fetch ,		_lowerCAmelCase ,		_lowerCAmelCase	) for i in range(10	)]
       lowercase__						:	Dict         = [future.result() for future in futures]
       self.assertEqual(_lowerCAmelCase ,		[[1, 10, 0, 8, 0, 18, 0, 0, 0, 2] for i in range(10	)]	)







 def 						UpperCAmelCase    (	self   :   int ,		UpperCAmelCase__   :   Tuple ,		UpperCAmelCase__   :   Union[str, Any]	):

    """simple docstring"""






    return tokenizer.encode(_lowerCAmelCase ,		truncation="""longest_first""" ,		padding="""longest"""	)










a    =       10**8
def       a__						(  A					):
   if n % 10 == 0:
      return False
   lowercase__						:	Optional[Any]         = str(A					)
   return s == s[::-1]
def       a__						(  ):
   lowercase__						:	Union[str, Any]         = set()
   lowercase__						:	Dict         = 1
   lowercase__						:	List[str]         = 5
   while sum_squares < LIMIT:
      lowercase__						:	Tuple         = first_square + 1
      while sum_squares < LIMIT:
         if is_palindrome(A					):
            answer.add(A					)
         last_square += 1
         sum_squares += last_square**2
      first_square += 1
      lowercase__						:	Any         = first_square**2 + (first_square + 1) ** 2

   return sum(A					)


if __name__ == "__main__":
 print(solution())


