



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


A__    :   Optional[int]           =					get_tests_dir('''fixtures/spiece.model''')



@require_sentencepiece
@require_tokenizers
class  snake_case__						(    SCREAMING_SNAKE_CASE_  ,     unittest.TestCase				):
 A__				= AlbertTokenizer
 A__				= AlbertTokenizerFast
 A__				= True
 A__				= True
 A__				= True
 def A_   (   self						:							List[str]  )      ->   List[Any]:







       '''simple docstring'''
       super().setUp()

       # We have a SentencePiece fixture for testing
       __snake_case :   str													=    AlbertTokenizer(__a  )
       tokenizer.save_pretrained(self.tmpdirname  )
 def A_   (   self						:							int      ,     __a						:							Dict  )      ->   Union[str, Any]:







       '''simple docstring'''
       __snake_case :   int													=    'this is a test'
       __snake_case :   Dict													=    'this is a test'
       return input_text, output_text
 def A_   (   self						:							int  )      ->   Union[str, Any]:







       '''simple docstring'''
       __snake_case :   Union[str, Any]													=    '<pad>'
       __snake_case :   str													=    0

       self.assertEqual(self.get_tokenizer()._convert_token_to_id(__a  )      ,     __a  )
       self.assertEqual(self.get_tokenizer()._convert_id_to_token(__a  )      ,     __a  )
 def A_   (   self						:							str  )      ->   List[str]:







       '''simple docstring'''
       __snake_case :   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 A_   (   self						:							Optional[Any]  )      ->   Optional[int]:







       '''simple docstring'''
       self.assertEqual(self.get_tokenizer().vocab_size      ,     30000  )
 def A_   (   self						:							Union[str, Any]  )      ->   List[Any]:







       '''simple docstring'''
       if not self.test_rust_tokenizer:
             return

       __snake_case :   Optional[Any]													=    self.get_tokenizer()
       __snake_case :   List[Any]													=    self.get_rust_tokenizer()

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

       __snake_case :   List[Any]													=    tokenizer.tokenize(__a  )
       __snake_case :   Union[str, Any]													=    rust_tokenizer.tokenize(__a  )
       self.assertListEqual(__a      ,     __a  )

       __snake_case :   int													=    tokenizer.encode(__a      ,     add_special_tokens=__a  )
       __snake_case :   Union[str, Any]													=    rust_tokenizer.encode(__a      ,     add_special_tokens=__a  )
       self.assertListEqual(__a      ,     __a  )

       __snake_case :   Dict													=    self.get_rust_tokenizer()
       __snake_case :   Optional[int]													=    tokenizer.encode(__a  )
       __snake_case :   Union[str, Any]													=    rust_tokenizer.encode(__a  )
       self.assertListEqual(__a      ,     __a  )
 def A_   (   self						:							Optional[int]  )      ->   Optional[Any]:







       '''simple docstring'''
       __snake_case :   Optional[Any]													=    AlbertTokenizer(__a      ,     keep_accents=__a  )

       __snake_case :   Union[str, Any]													=    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]  )

       __snake_case :   Tuple													=    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', 'é', '.']  )
       __snake_case :   Optional[Any]													=    tokenizer.convert_tokens_to_ids(__a  )
       self.assertListEqual(__a      ,     [31, 23, 386, 19, 561, 3050, 15, 17, 48, 25, 8256, 18, 1, 9]  )

       __snake_case :   Any													=    tokenizer.convert_ids_to_tokens(__a  )
       self.assertListEqual(
           __a      ,     ['▁i', '▁was', '▁born', '▁in', '▁9', '2000', ',', '▁and', '▁this', '▁is', '▁fal', 's', '<unk>', '.']      ,     )
 def A_   (   self						:							Optional[int]  )      ->   int:







       '''simple docstring'''
       __snake_case :   str													=    AlbertTokenizer(__a  )

       __snake_case :   Tuple													=    tokenizer.encode('sequence builders'  )
       __snake_case :   List[Any]													=    tokenizer.encode('multi-sequence build'  )

       __snake_case :   Dict													=    tokenizer.build_inputs_with_special_tokens(__a  )
       __snake_case :   Dict													=    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 A_   (   self						:							Union[str, Any]  )      ->   List[Any]:







       '''simple docstring'''
       # fmt: off
       __snake_case :   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, 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, 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 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'''





from abc import ABC, abstractmethod
from argparse import ArgumentParser



class  snake_case__						(    SCREAMING_SNAKE_CASE_				):
 @staticmethod
 @abstractmethod
 def A_   (   __a						:							ArgumentParser  )      ->   List[str]:







       '''simple docstring'''
       raise NotImplementedError()





 @abstractmethod
 def A_   (   self						:							Optional[Any]  )      ->   Optional[Any]:







       '''simple docstring'''
       raise NotImplementedError()



