





import json
import os
import unittest

from transformers import MgpstrTokenizer
from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin






@require_tokenizers
class        _a(    _UpperCamelCase	,   unittest.TestCase    ):
		lowerCamelCase__     :Optional[int]   				=		MgpstrTokenizer
		lowerCamelCase__     :Tuple   				=		False
		lowerCamelCase__     :Tuple   				=		{}
		lowerCamelCase__     :Optional[int]   				=		False







		def        lowercase       (    self				)      ->      Tuple:


							'''simple docstring'''

							super().setUp()

							# fmt: off
							_snake_case       :					Tuple				       =   ["[GO]", "[s]", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
							# fmt: on
							_snake_case       :					List[str]				       =   dict(zip(__a ,						range(len(__a				)				)				)				)

							_snake_case       :					List[str]				       =   os.path.join(self.tmpdirname ,						VOCAB_FILES_NAMES["vocab_file"]				)
							with open(self.vocab_file ,						"w" ,						encoding="utf-8"				) as fp:
												fp.write(json.dumps(__a				) + "\n"				)







		def        lowercase       (    self ,						**__snake_case				)      ->      Optional[int]:


							'''simple docstring'''

							return MgpstrTokenizer.from_pretrained(self.tmpdirname ,						**__a				)







		def        lowercase       (    self ,						__snake_case				)      ->      Tuple:


							'''simple docstring'''

							_snake_case       :					Tuple				       =   "tester"
							_snake_case       :					Optional[int]				       =   "tester"
							return input_text, output_text







		@unittest.skip("MGP-STR always lower cases letters."				)
		def        lowercase       (    self				)      ->      Any:


							'''simple docstring'''

							pass







		def        lowercase       (    self				)      ->      List[Any]:


							'''simple docstring'''

							_snake_case       :					Optional[int]				       =   self.get_tokenizers(do_lower_case=__a				)
							for tokenizer in tokenizers:
												with self.subTest(f"""{tokenizer.__class__.__name__}"""				):
																	_snake_case       :					Tuple				       =   "[SPECIAL_TOKEN]"

																	tokenizer.add_special_tokens({"cls_token": special_token}				)
																	_snake_case       :					List[str]				       =   tokenizer.encode([special_token] ,						add_special_tokens=__a				)
																	self.assertEqual(len(__a				) ,						1				)

																	_snake_case       :					str				       =   tokenizer.decode(__a ,						skip_special_tokens=__a				)
																	self.assertTrue(special_token not in decoded				)







		def        lowercase       (    self				)      ->      Dict:


							'''simple docstring'''

							_snake_case       :					int				       =   self.get_tokenizers()
							for tokenizer in tokenizers:
												with self.subTest(f"""{tokenizer.__class__.__name__}"""				):
																	_snake_case       :					Dict				       =   self.get_input_output_texts(__a				)

																	_snake_case       :					Tuple				       =   tokenizer.tokenize(__a				)
																	_snake_case       :					Dict				       =   tokenizer.convert_tokens_to_ids(__a				)
																	_snake_case       :					str				       =   tokenizer.encode(__a ,						add_special_tokens=__a				)
																	self.assertListEqual(__a ,						__a				)

																	_snake_case       :					Dict				       =   tokenizer.convert_ids_to_tokens(__a				)
																	self.assertNotEqual(len(__a				) ,						0				)
																	_snake_case       :					Dict				       =   tokenizer.decode(__a				)
																	self.assertIsInstance(__a ,						__a				)

																	self.assertEqual(text_a.replace(" " ,						""				) ,						__a				)







		@unittest.skip("MGP-STR tokenizer only handles one sequence."				)
		def        lowercase       (    self				)      ->      int:


							'''simple docstring'''

							pass







		@unittest.skip("inputs cannot be pretokenized in MgpstrTokenizer"				)
		def        lowercase       (    self				)      ->      List[str]:


							'''simple docstring'''

							pass






import re







def    A				(							UpperCAmelCase				):
					_snake_case       :					Any				       =   re.compile(R"^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$"				)
					if match := re.search(UpperCAmelCase  ,  UpperCAmelCase				):
										return match.string == phone
					return False


if __name__ == "__main__":
							print(indian_phone_validator('+918827897895'))