


'''simple docstring'''

import unittest

from transformers import AlbertTokenizer, AlbertTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin


lowerCAmelCase				:Optional[int]        =      get_tests_dir('''fixtures/spiece.model''')
@require_sentencepiece
@require_tokenizers
class _lowerCamelCase	(						lowercase__		,					unittest.TestCase							):



		'''simple docstring'''







		A_     :      Dict				   =    AlbertTokenizer
		A_     :      List[Any]				   =    AlbertTokenizerFast
		A_     :      str				   =    True
		A_     :      Any				   =    True
		A_     :      Union[str, Any]				   =    True







		def        __lowerCAmelCase		( self		:						str      )  ->			List[Any]:
			super().setUp()

			# We have a SentencePiece fixture for testing
			__magic_name__	:   Tuple					     =					AlbertTokenizer(_A      )
			tokenizer.save_pretrained(self.tmpdirname      )







		def        __lowerCAmelCase		( self		:						Optional[int]  ,					_A		:						List[str]      )  ->			str:
			__magic_name__	:   List[Any]					     =					'this is a test'
			__magic_name__	:   List[str]					     =					'this is a test'
			return input_text, output_text







		def        __lowerCAmelCase		( self		:						Any      )  ->			str:
			__magic_name__	:   str					     =					'<pad>'
			__magic_name__	:   Union[str, Any]					     =					0

			self.assertEqual(self.get_tokenizer()._convert_token_to_id(_A      )  ,					_A      )
			self.assertEqual(self.get_tokenizer()._convert_id_to_token(_A      )  ,					_A      )







		def        __lowerCAmelCase		( self		:						Optional[Any]      )  ->			List[Any]:
			__magic_name__	:   List[Any]					     =					list(self.get_tokenizer().get_vocab().keys()      )

			self.assertEqual(vocab_keys[0]  ,					'<pad>'      )
			self.assertEqual(vocab_keys[1]  ,					'<unk>'      )
			self.assertEqual(vocab_keys[-1]  ,					'▁eloquent'      )
			self.assertEqual(len(_A      )  ,					30000      )







		def        __lowerCAmelCase		( self		:						Tuple      )  ->			List[Any]:
			self.assertEqual(self.get_tokenizer().vocab_size  ,					30000      )







		def        __lowerCAmelCase		( self		:						List[Any]      )  ->			Optional[int]:
			if not self.test_rust_tokenizer:
				return

			__magic_name__	:   Dict					     =					self.get_tokenizer()
			__magic_name__	:   str					     =					self.get_rust_tokenizer()

			__magic_name__	:   List[Any]					     =					'I was born in 92000, and this is falsé.'

			__magic_name__	:   Union[str, Any]					     =					tokenizer.tokenize(_A      )
			__magic_name__	:   Optional[int]					     =					rust_tokenizer.tokenize(_A      )
			self.assertListEqual(_A  ,					_A      )

			__magic_name__	:   Optional[int]					     =					tokenizer.encode(_A  ,					add_special_tokens=_A      )
			__magic_name__	:   List[str]					     =					rust_tokenizer.encode(_A  ,					add_special_tokens=_A      )
			self.assertListEqual(_A  ,					_A      )

			__magic_name__	:   Any					     =					self.get_rust_tokenizer()
			__magic_name__	:   List[Any]					     =					tokenizer.encode(_A      )
			__magic_name__	:   Union[str, Any]					     =					rust_tokenizer.encode(_A      )
			self.assertListEqual(_A  ,					_A      )







		def        __lowerCAmelCase		( self		:						List[str]      )  ->			int:
			__magic_name__	:   Any					     =					AlbertTokenizer(_A  ,					keep_accents=_A      )

			__magic_name__	:   Tuple					     =					tokenizer.tokenize('This is a test'      )
			self.assertListEqual(_A  ,					['▁this', '▁is', '▁a', '▁test']      )

			self.assertListEqual(tokenizer.convert_tokens_to_ids(_A      )  ,					[48, 25, 21, 1289]      )

			__magic_name__	:   Optional[int]					     =					tokenizer.tokenize('I was born in 92000, and this is falsé.'      )
			self.assertListEqual(
			    _A  ,					['▁i', '▁was', '▁born', '▁in', '▁9', '2000', ',', '▁and', '▁this', '▁is', '▁fal', 's', 'é', '.']      )
			__magic_name__	:   Tuple					     =					tokenizer.convert_tokens_to_ids(_A      )
			self.assertListEqual(_A  ,					[31, 23, 386, 19, 561, 3050, 15, 17, 48, 25, 8256, 18, 1, 9]      )

			__magic_name__	:   List[str]					     =					tokenizer.convert_ids_to_tokens(_A      )
			self.assertListEqual(
			    _A  ,					['▁i', '▁was', '▁born', '▁in', '▁9', '2000', ',', '▁and', '▁this', '▁is', '▁fal', 's', '<unk>', '.']  ,					)







		def        __lowerCAmelCase		( self		:						Dict      )  ->			Union[str, Any]:
			__magic_name__	:   List[str]					     =					AlbertTokenizer(_A      )

			__magic_name__	:   List[str]					     =					tokenizer.encode('sequence builders'      )
			__magic_name__	:   int					     =					tokenizer.encode('multi-sequence build'      )

			__magic_name__	:   Tuple					     =					tokenizer.build_inputs_with_special_tokens(_A      )
			__magic_name__	:   Any					     =					tokenizer.build_inputs_with_special_tokens(_A  ,					_A      )

			assert encoded_sentence == [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id]
			assert encoded_pair == [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id] + text_a + [
			    tokenizer.sep_token_id
			]







		@slow
		def        __lowerCAmelCase		( self		:						Union[str, Any]      )  ->			Optional[int]:
			# fmt: off
			__magic_name__	:   Optional[Any]					     =					{'attention_mask': [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], 'input_ids': [[2, 21970, 13, 5, 6092, 167, 28, 7103, 2153, 673, 8, 7028, 12051, 18, 17, 7103, 2153, 673, 8, 3515, 18684, 8, 4461, 6, 1927, 297, 8, 12060, 2607, 18, 13, 5, 4461, 15, 10538, 38, 8, 135, 15, 822, 58, 15, 993, 10363, 15, 1460, 8005, 4461, 15, 993, 255, 2328, 9, 9, 9, 6, 26, 1112, 816, 3260, 13, 5, 103, 2377, 6, 17, 1112, 816, 2782, 13, 5, 103, 10641, 6, 29, 84, 2512, 2430, 782, 18684, 2761, 19, 808, 2430, 2556, 17, 855, 1480, 9477, 4091, 128, 11712, 15, 7103, 2153, 673, 17, 24883, 9990, 9, 3], [2, 11502, 25, 1006, 20, 782, 8, 11809, 855, 1732, 19393, 18667, 37, 367, 21018, 69, 1854, 34, 11860, 19124, 27, 156, 225, 17, 193, 4141, 19, 65, 9124, 9, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [2, 14, 2231, 886, 2385, 17659, 84, 14, 16792, 1952, 9, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]}  # noqa: E501
			# fmt: on

			self.tokenizer_integration_test_util(
			    expected_encoding=_A  ,					model_name='albert-base-v2'  ,					revision='6b6560eaf5ff2e250b00c50f380c5389a9c2d82e'  ,					)



'''simple docstring'''

def lowerCamelCase      (      lowerCAmelCase    :     str		):





	"""simple docstring"""







	return "".join(chr(ord(lowerCAmelCase		) - 32		) if 'a' <= char <= 'z' else char for char in word		)


if __name__ == "__main__":
							from doctest import testmod

							testmod()