
def        __lowercase(							__snake_case				:		int    ,__snake_case				:		List[str]					)       ->   str:
       __snake_case						       =   1
       while b > 0:
              if b & 1:
                     res *= a

              a *= a
              b >>= 1

       return res
def        __lowercase(							__snake_case				:		List[Any]    ,__snake_case				:		Tuple    ,__snake_case				:		Optional[int]					)       ->   str:
       __snake_case						       =   1
       while b > 0:
              if b & 1:
                     __snake_case						       =   ((res % c) * (a % c)) % c

              a *= a
              b >>= 1

       return res


import json
import os
import unittest

from transformers import HerbertTokenizer, HerbertTokenizerFast
from transformers.models.herbert.tokenization_herbert import VOCAB_FILES_NAMES
from transformers.testing_utils import get_tests_dir, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin







@require_tokenizers
class  _lowerCamelCase			(lowerCamelCase							,					unittest.TestCase					):
     lowercase__				  =			HerbertTokenizer
     lowercase__				  =			HerbertTokenizerFast
     lowercase__				  =			True

     def 						__lowerCamelCase				(  self    ):
            super().setUp()

            # Use a simpler test file without japanese/chinese characters
            with open(f'''{get_tests_dir()}/fixtures/sample_text_no_unicode.txt'''							,       encoding='utf-8'    ) as f_data:
                   __snake_case						       =   f_data.read().replace('\n\n'							,       '\n'    ).strip()

            __snake_case						       =   [
                '<s>',
                '</s>',
                'l',
                'o',
                'w',
                'e',
                'r',
                's',
                't',
                'i',
                'd',
                'n',
                'w</w>',
                'r</w>',
                't</w>',
                'lo',
                'low',
                'er</w>',
                'low</w>',
                'lowest</w>',
                'newer</w>',
                'wider</w>',
                ',</w>',
                '<unk>',
            ]
            __snake_case						       =   dict(zip(SCREAMING_SNAKE_CASE_							,       range(len(SCREAMING_SNAKE_CASE_    )    )    )    )
            __snake_case						       =   ['l o 123', 'lo w 1456', 'e r</w> 1789', '']

            __snake_case						       =   os.path.join(self.tmpdirname							,       VOCAB_FILES_NAMES['vocab_file']    )
            __snake_case						       =   os.path.join(self.tmpdirname							,       VOCAB_FILES_NAMES['merges_file']    )
            with open(self.vocab_file							,       'w'    ) as fp:
                   fp.write(json.dumps(SCREAMING_SNAKE_CASE_    )    )
            with open(self.merges_file							,       'w'    ) as fp:
                   fp.write('\n'.join(SCREAMING_SNAKE_CASE_    )    )

     def 						__lowerCamelCase				(  self							,       SCREAMING_SNAKE_CASE_    ):
            __snake_case						       =   'lower newer'
            __snake_case						       =   'lower newer'
            return input_text, output_text

     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   self.tokenizer_class(vocab_file=self.vocab_file							,       merges_file=self.merges_file    )

            __snake_case						       =   'lower'
            __snake_case						       =   ['low', 'er</w>']
            __snake_case						       =   tokenizer.tokenize(SCREAMING_SNAKE_CASE_    )
            self.assertListEqual(SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_    )

            __snake_case						       =   tokens + ['<unk>']
            __snake_case						       =   [16, 17, 23]
            self.assertListEqual(tokenizer.convert_tokens_to_ids(SCREAMING_SNAKE_CASE_    )							,       SCREAMING_SNAKE_CASE_    )

     def 						__lowerCamelCase				(  self    ):
            if not self.test_rust_tokenizer:
                   return

            __snake_case						       =   self.get_tokenizer()
            __snake_case						       =   self.get_rust_tokenizer()

            __snake_case						       =   'lower,newer'

            __snake_case						       =   tokenizer.tokenize(SCREAMING_SNAKE_CASE_    )
            __snake_case						       =   rust_tokenizer.tokenize(SCREAMING_SNAKE_CASE_    )
            self.assertListEqual(SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_    )

            __snake_case						       =   tokenizer.encode(SCREAMING_SNAKE_CASE_							,       add_special_tokens=SCREAMING_SNAKE_CASE_    )
            __snake_case						       =   rust_tokenizer.encode(SCREAMING_SNAKE_CASE_							,       add_special_tokens=SCREAMING_SNAKE_CASE_    )
            self.assertListEqual(SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_    )

            __snake_case						       =   self.get_rust_tokenizer()
            __snake_case						       =   tokenizer.encode(SCREAMING_SNAKE_CASE_    )
            __snake_case						       =   rust_tokenizer.encode(SCREAMING_SNAKE_CASE_    )
            self.assertListEqual(SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_    )

     @slow
     def 						__lowerCamelCase				(  self    ):
            __snake_case						       =   self.tokenizer_class.from_pretrained('allegro/herbert-base-cased'    )

            __snake_case						       =   tokenizer.encode('konstruowanie sekwencji'							,       add_special_tokens=SCREAMING_SNAKE_CASE_    )
            __snake_case						       =   tokenizer.encode('konstruowanie wielu sekwencji'							,       add_special_tokens=SCREAMING_SNAKE_CASE_    )

            __snake_case						       =   tokenizer.build_inputs_with_special_tokens(SCREAMING_SNAKE_CASE_    )
            __snake_case						       =   tokenizer.build_inputs_with_special_tokens(SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_    )

            assert encoded_sentence == [0] + text + [2]
            assert encoded_pair == [0] + text + [2] + text_a + [2]
