





'''simple docstring'''

import shutil
import tempfile
import unittest

from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available
from transformers.testing_utils import (
    get_tests_dir,
    nested_simplify,
    require_sentencepiece,
    require_tokenizers,
    require_torch,
)

from ...test_tokenization_common import TokenizerTesterMixin


lowercase__		:     Tuple			=							get_tests_dir('fixtures/test_sentencepiece.model')


if is_torch_available():
   from transformers.models.mbart.modeling_mbart import shift_tokens_right

lowercase__		:     Dict			=							25_00_04
lowercase__		:     List[Any]			=							25_00_20
@require_sentencepiece
@require_tokenizers
class 							__lowerCAmelCase	(       __magic_name__		,		unittest.TestCase					):






       """simple docstring"""
       _snake_case      :	Dict									=       MBartTokenizer
       _snake_case      :	Tuple									=       MBartTokenizerFast
       _snake_case      :	Union[str, Any]									=       True
       _snake_case      :	Tuple									=       True





       def snake_case__		(				self  :						List[Any]	)       ->	Dict:

            '''simple docstring'''




            super().setUp()

            # We have a SentencePiece fixture for testing
            _UpperCamelCase							       =			MBartTokenizer(lowerCAmelCase__			,					keep_accents=lowerCAmelCase__	)
            tokenizer.save_pretrained(self.tmpdirname	)





       def snake_case__		(				self  :						Any	)       ->	Optional[Any]:

            '''simple docstring'''




            _UpperCamelCase							       =			MBartTokenizer(lowerCAmelCase__			,					keep_accents=lowerCAmelCase__	)

            _UpperCamelCase							       =			tokenizer.tokenize('''This is a test'''	)
            self.assertListEqual(lowerCAmelCase__			,					['''▁This''', '''▁is''', '''▁a''', '''▁t''', '''est''']	)

            self.assertListEqual(
                tokenizer.convert_tokens_to_ids(lowerCAmelCase__	)			,					[value + tokenizer.fairseq_offset for value in [285, 46, 10, 170, 382]]			,					)

            _UpperCamelCase							       =			tokenizer.tokenize('''I was born in 92000, and this is falsé.'''	)
            self.assertListEqual(
                lowerCAmelCase__			,					[
                    SPIECE_UNDERLINE + '''I''',
                    SPIECE_UNDERLINE + '''was''',
                    SPIECE_UNDERLINE + '''b''',
                    '''or''',
                    '''n''',
                    SPIECE_UNDERLINE + '''in''',
                    SPIECE_UNDERLINE + '''''',
                    '''9''',
                    '''2''',
                    '''0''',
                    '''0''',
                    '''0''',
                    ''',''',
                    SPIECE_UNDERLINE + '''and''',
                    SPIECE_UNDERLINE + '''this''',
                    SPIECE_UNDERLINE + '''is''',
                    SPIECE_UNDERLINE + '''f''',
                    '''al''',
                    '''s''',
                    '''é''',
                    '''.''',
                ]			,					)
            _UpperCamelCase							       =			tokenizer.convert_tokens_to_ids(lowerCAmelCase__	)
            self.assertListEqual(
                lowerCAmelCase__			,					[
                    value + tokenizer.fairseq_offset
                    for value in [8, 21, 84, 55, 24, 19, 7, 2, 602, 347, 347, 347, 3, 12, 66, 46, 72, 80, 6, 2, 4]
                    #                                       ^ unk: 2 + 1 = 3                  unk: 2 + 1 = 3 ^
                ]			,					)

            _UpperCamelCase							       =			tokenizer.convert_ids_to_tokens(lowerCAmelCase__	)
            self.assertListEqual(
                lowerCAmelCase__			,					[
                    SPIECE_UNDERLINE + '''I''',
                    SPIECE_UNDERLINE + '''was''',
                    SPIECE_UNDERLINE + '''b''',
                    '''or''',
                    '''n''',
                    SPIECE_UNDERLINE + '''in''',
                    SPIECE_UNDERLINE + '''''',
                    '''<unk>''',
                    '''2''',
                    '''0''',
                    '''0''',
                    '''0''',
                    ''',''',
                    SPIECE_UNDERLINE + '''and''',
                    SPIECE_UNDERLINE + '''this''',
                    SPIECE_UNDERLINE + '''is''',
                    SPIECE_UNDERLINE + '''f''',
                    '''al''',
                    '''s''',
                    '''<unk>''',
                    '''.''',
                ]			,					)







       def snake_case__		(				self  :						Optional[int]	)       ->	Tuple:

            '''simple docstring'''




            if not self.test_slow_tokenizer:
                 # as we don't have a slow version, we can't compare the outputs between slow and fast versions
                 return

            _UpperCamelCase							       =			(self.rust_tokenizer_class, '''hf-internal-testing/tiny-random-mbart''', {})
            for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
                 with self.subTest(f"""{tokenizer.__class__.__name__} ({pretrained_name})"""	):
                      _UpperCamelCase							       =			self.rust_tokenizer_class.from_pretrained(lowerCAmelCase__			,					**lowerCAmelCase__	)
                      _UpperCamelCase							       =			self.tokenizer_class.from_pretrained(lowerCAmelCase__			,					**lowerCAmelCase__	)

                      _UpperCamelCase							       =			tempfile.mkdtemp()

                      _UpperCamelCase							       =			tokenizer_r.save_pretrained(lowerCAmelCase__	)
                      _UpperCamelCase							       =			tokenizer_p.save_pretrained(lowerCAmelCase__	)

                      # Checks it save with the same files + the tokenizer.json file for the fast one
                      self.assertTrue(any('''tokenizer.json''' in f for f in tokenizer_r_files	)	)
                      _UpperCamelCase							       =			tuple(f for f in tokenizer_r_files if '''tokenizer.json''' not in f	)
                      self.assertSequenceEqual(lowerCAmelCase__			,					lowerCAmelCase__	)

                      # Checks everything loads correctly in the same way
                      _UpperCamelCase							       =			tokenizer_r.from_pretrained(lowerCAmelCase__	)
                      _UpperCamelCase							       =			tokenizer_p.from_pretrained(lowerCAmelCase__	)

                      # Check special tokens are set accordingly on Rust and Python
                      for key in tokenizer_pp.special_tokens_map:
                           self.assertTrue(hasattr(lowerCAmelCase__			,					lowerCAmelCase__	)	)
                           # self.assertEqual(getattr(tokenizer_rp, key), getattr(tokenizer_pp, key))
                           # self.assertEqual(getattr(tokenizer_rp, key + "_id"), getattr(tokenizer_pp, key + "_id"))

                      shutil.rmtree(lowerCAmelCase__	)

                      # Save tokenizer rust, legacy_format=True
                      _UpperCamelCase							       =			tempfile.mkdtemp()

                      _UpperCamelCase							       =			tokenizer_r.save_pretrained(lowerCAmelCase__			,					legacy_format=lowerCAmelCase__	)
                      _UpperCamelCase							       =			tokenizer_p.save_pretrained(lowerCAmelCase__	)

                      # Checks it save with the same files
                      self.assertSequenceEqual(lowerCAmelCase__			,					lowerCAmelCase__	)

                      # Checks everything loads correctly in the same way
                      _UpperCamelCase							       =			tokenizer_r.from_pretrained(lowerCAmelCase__	)
                      _UpperCamelCase							       =			tokenizer_p.from_pretrained(lowerCAmelCase__	)

                      # Check special tokens are set accordingly on Rust and Python
                      for key in tokenizer_pp.special_tokens_map:
                           self.assertTrue(hasattr(lowerCAmelCase__			,					lowerCAmelCase__	)	)

                      shutil.rmtree(lowerCAmelCase__	)

                      # Save tokenizer rust, legacy_format=False
                      _UpperCamelCase							       =			tempfile.mkdtemp()

                      _UpperCamelCase							       =			tokenizer_r.save_pretrained(lowerCAmelCase__			,					legacy_format=lowerCAmelCase__	)
                      _UpperCamelCase							       =			tokenizer_p.save_pretrained(lowerCAmelCase__	)

                      # Checks it saved the tokenizer.json file
                      self.assertTrue(any('''tokenizer.json''' in f for f in tokenizer_r_files	)	)

                      # Checks everything loads correctly in the same way
                      _UpperCamelCase							       =			tokenizer_r.from_pretrained(lowerCAmelCase__	)
                      _UpperCamelCase							       =			tokenizer_p.from_pretrained(lowerCAmelCase__	)

                      # Check special tokens are set accordingly on Rust and Python
                      for key in tokenizer_pp.special_tokens_map:
                           self.assertTrue(hasattr(lowerCAmelCase__			,					lowerCAmelCase__	)	)

                      shutil.rmtree(lowerCAmelCase__	)

@require_torch
@require_sentencepiece
@require_tokenizers
class 							__lowerCAmelCase	(       unittest.TestCase					):






       """simple docstring"""
       _snake_case      :	Tuple									=       'facebook/mbart-large-en-ro'
       _snake_case      :	List[Any]									=       [
           ' UN Chief Says There Is No Military Solution in Syria',
           ' Secretary-General Ban Ki-moon says his response to Russia\'s stepped up military support for Syria is that "there is no military solution" to the nearly five-year conflict and more weapons will only worsen the violence and misery for millions of people.',
       ]
       _snake_case      :	Any									=       [
           'Şeful ONU declară că nu există o soluţie militară în Siria',
           'Secretarul General Ban Ki-moon declară că răspunsul său la intensificarea sprijinului militar al Rusiei'
           ' pentru Siria este că "nu există o soluţie militară" la conflictul de aproape cinci ani şi că noi arme nu vor'
           ' face decât să înrăutăţească violenţele şi mizeria pentru milioane de oameni.',
       ]
       _snake_case      :	Any									=       [8_2_7_4, 1_2_7_8_7_3, 2_5_9_1_6, 7, 8_6_2_2, 2_0_7_1, 4_3_8, 6_7_4_8_5, 5_3, 1_8_7_8_9_5, 2_3, 5_1_7_1_2, 2, EN_CODE]





       @classmethod
       def snake_case__		(				cls  :						str	)       ->	int:

            '''simple docstring'''




            _UpperCamelCase							       =			MBartTokenizer.from_pretrained(
                cls.checkpoint_name			,					src_lang='''en_XX'''			,					tgt_lang='''ro_RO'''	)
            _UpperCamelCase							       =			1
            return cls





       def snake_case__		(				self  :						Any	)       ->	str:

            '''simple docstring'''




            self.assertEqual(self.tokenizer.fairseq_tokens_to_ids['''ar_AR''']			,					250001	)
            self.assertEqual(self.tokenizer.fairseq_tokens_to_ids['''en_EN''']			,					250004	)
            self.assertEqual(self.tokenizer.fairseq_tokens_to_ids['''ro_RO''']			,					250020	)





       def snake_case__		(				self  :						Optional[Any]	)       ->	List[str]:

            '''simple docstring'''




            _UpperCamelCase							       =			self.tokenizer.batch_encode_plus(self.src_text	).input_ids[0]
            self.assertListEqual(self.expected_src_tokens			,					lowerCAmelCase__	)





       def snake_case__		(				self  :						Union[str, Any]	)       ->	int:

            '''simple docstring'''




            self.assertIn(lowerCAmelCase__			,					self.tokenizer.all_special_ids	)
            _UpperCamelCase							       =			[RO_CODE, 884, 9019, 96, 9, 916, 86792, 36, 18743, 15596, 5, 2]
            _UpperCamelCase							       =			self.tokenizer.decode(lowerCAmelCase__			,					skip_special_tokens=lowerCAmelCase__	)
            _UpperCamelCase							       =			self.tokenizer.decode(generated_ids[1:]			,					skip_special_tokens=lowerCAmelCase__	)
            self.assertEqual(lowerCAmelCase__			,					lowerCAmelCase__	)
            self.assertNotIn(self.tokenizer.eos_token			,					lowerCAmelCase__	)





       def snake_case__		(				self  :						Dict	)       ->	Union[str, Any]:

            '''simple docstring'''




            _UpperCamelCase							       =			['''this is gunna be a long sentence ''' * 20]
            assert isinstance(src_text[0]			,					lowerCAmelCase__	)
            _UpperCamelCase							       =			10
            _UpperCamelCase							       =			self.tokenizer(lowerCAmelCase__			,					max_length=lowerCAmelCase__			,					truncation=lowerCAmelCase__	).input_ids[0]
            self.assertEqual(ids[-2]			,					2	)
            self.assertEqual(ids[-1]			,					lowerCAmelCase__	)
            self.assertEqual(len(lowerCAmelCase__	)			,					lowerCAmelCase__	)





       def snake_case__		(				self  :						Dict	)       ->	List[Any]:

            '''simple docstring'''




            self.assertListEqual(self.tokenizer.convert_tokens_to_ids(['''<mask>''', '''ar_AR''']	)			,					[250026, 250001]	)





       def snake_case__		(				self  :						int	)       ->	List[Any]:

            '''simple docstring'''




            _UpperCamelCase							       =			tempfile.mkdtemp()
            _UpperCamelCase							       =			self.tokenizer.fairseq_tokens_to_ids
            self.tokenizer.save_pretrained(lowerCAmelCase__	)
            _UpperCamelCase							       =			MBartTokenizer.from_pretrained(lowerCAmelCase__	)
            self.assertDictEqual(new_tok.fairseq_tokens_to_ids			,					lowerCAmelCase__	)





       @require_torch
       def snake_case__		(				self  :						int	)       ->	Optional[Any]:

            '''simple docstring'''




            _UpperCamelCase							       =			self.tokenizer(self.src_text			,					text_target=self.tgt_text			,					padding=lowerCAmelCase__			,					return_tensors='''pt'''	)
            _UpperCamelCase							       =			shift_tokens_right(batch['''labels''']			,					self.tokenizer.pad_token_id	)

            # fairseq batch: https://gist.github.com/sshleifer/cba08bc2109361a74ac3760a7e30e4f4
            assert batch.input_ids[1][-2:].tolist() == [2, EN_CODE]
            assert batch.decoder_input_ids[1][0].tolist() == RO_CODE
            assert batch.decoder_input_ids[1][-1] == 2
            assert batch.labels[1][-2:].tolist() == [2, RO_CODE]





       @require_torch
       def snake_case__		(				self  :						Tuple	)       ->	Tuple:

            '''simple docstring'''




            _UpperCamelCase							       =			self.tokenizer(
                self.src_text			,					text_target=self.tgt_text			,					padding=lowerCAmelCase__			,					truncation=lowerCAmelCase__			,					max_length=len(self.expected_src_tokens	)			,					return_tensors='''pt'''			,					)

            _UpperCamelCase							       =			shift_tokens_right(batch['''labels''']			,					self.tokenizer.pad_token_id	)

            self.assertIsInstance(lowerCAmelCase__			,					lowerCAmelCase__	)

            self.assertEqual((2, 14)			,					batch.input_ids.shape	)
            self.assertEqual((2, 14)			,					batch.attention_mask.shape	)
            _UpperCamelCase							       =			batch.input_ids.tolist()[0]
            self.assertListEqual(self.expected_src_tokens			,					lowerCAmelCase__	)
            self.assertEqual(2			,					batch.decoder_input_ids[0, -1]	)  # EOS
            # Test that special tokens are reset
            self.assertEqual(self.tokenizer.prefix_tokens			,					[]	)
            self.assertEqual(self.tokenizer.suffix_tokens			,					[self.tokenizer.eos_token_id, EN_CODE]	)





       def snake_case__		(				self  :						Dict	)       ->	Optional[Any]:

            '''simple docstring'''




            _UpperCamelCase							       =			self.tokenizer(self.src_text			,					padding=lowerCAmelCase__			,					truncation=lowerCAmelCase__			,					max_length=3			,					return_tensors='''pt'''	)
            _UpperCamelCase							       =			self.tokenizer(
                text_target=self.tgt_text			,					padding=lowerCAmelCase__			,					truncation=lowerCAmelCase__			,					max_length=10			,					return_tensors='''pt'''	)
            _UpperCamelCase							       =			targets['''input_ids''']
            _UpperCamelCase							       =			shift_tokens_right(lowerCAmelCase__			,					self.tokenizer.pad_token_id	)

            self.assertEqual(batch.input_ids.shape[1]			,					3	)
            self.assertEqual(batch.decoder_input_ids.shape[1]			,					10	)







       @require_torch
       def snake_case__		(				self  :						str	)       ->	Tuple:

            '''simple docstring'''




            _UpperCamelCase							       =			self.tokenizer._build_translation_inputs(
                '''A test'''			,					return_tensors='''pt'''			,					src_lang='''en_XX'''			,					tgt_lang='''ar_AR'''	)

            self.assertEqual(
                nested_simplify(lowerCAmelCase__	)			,					{
                    # A, test, EOS, en_XX
                    '''input_ids''': [[62, 3034, 2, 250004]],
                    '''attention_mask''': [[1, 1, 1, 1]],
                    # ar_AR
                    '''forced_bos_token_id''': 250001,
                }			,					)








'''simple docstring'''





import pickle
import shutil
import tempfile
import unittest

from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast
from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow
from transformers.utils import cached_property

from ...test_tokenization_common import TokenizerTesterMixin


SCREAMING_SNAKE_CASE__          =  get_tests_dir("fixtures/test_sentencepiece.model")


@require_sentencepiece
@require_tokenizers
class 					snake_case			(UpperCamelCase		,   unittest.TestCase ):
       lowerCAmelCase__	:List[Any]     =       XGLMTokenizer
       lowerCAmelCase__	:Tuple     =       XGLMTokenizerFast
       lowerCAmelCase__	:Any     =       True
       lowerCAmelCase__	:List[Any]     =       True



       def 				_a   (					self   )	->				Tuple:
           super().setUp()

           # We have a SentencePiece fixture for testing
           lowercase__									=    XGLMTokenizer(UpperCAmelCase_  ,keep_accents=UpperCAmelCase_   )
           tokenizer.save_pretrained(self.tmpdirname   )



       def 				_a   (					self   )	->				Tuple:
           lowercase__									=    "<pad>"
           lowercase__									=    1

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



       def 				_a   (					self   )	->				Dict:
           lowercase__									=    list(self.get_tokenizer().get_vocab().keys()   )

           self.assertEqual(vocab_keys[0]  ,"<s>"   )
           self.assertEqual(vocab_keys[1]  ,"<pad>"   )
           self.assertEqual(len(UpperCAmelCase_   )  ,1_008   )



       def 				_a   (					self   )	->				Union[str, Any]:
           self.assertEqual(self.get_tokenizer().vocab_size  ,1_008   )



       def 				_a   (					self   )	->				Dict:
           lowercase__									=    XGLMTokenizer(UpperCAmelCase_  ,keep_accents=UpperCAmelCase_   )

           lowercase__									=    tokenizer.tokenize("This is a test"   )
           self.assertListEqual(UpperCAmelCase_  ,["▁This", "▁is", "▁a", "▁t", "est"]   )

           self.assertListEqual(
               tokenizer.convert_tokens_to_ids(UpperCAmelCase_   )  ,[value + tokenizer.fairseq_offset for value in [285, 46, 10, 170, 382]]  ,)

           lowercase__									=    tokenizer.tokenize("I was born in 92000, and this is falsé."   )
           self.assertListEqual(
               UpperCAmelCase_  ,[
                   SPIECE_UNDERLINE + "I",
                   SPIECE_UNDERLINE + "was",
                   SPIECE_UNDERLINE + "b",
                   "or",
                   "n",
                   SPIECE_UNDERLINE + "in",
                   SPIECE_UNDERLINE + "",
                   "9",
                   "2",
                   "0",
                   "0",
                   "0",
                   ",",
                   SPIECE_UNDERLINE + "and",
                   SPIECE_UNDERLINE + "this",
                   SPIECE_UNDERLINE + "is",
                   SPIECE_UNDERLINE + "f",
                   "al",
                   "s",
                   "é",
                   ".",
               ]  ,)
           lowercase__									=    tokenizer.convert_tokens_to_ids(UpperCAmelCase_   )
           self.assertListEqual(
               UpperCAmelCase_  ,[
                   value + tokenizer.fairseq_offset
                   for value in [8, 21, 84, 55, 24, 19, 7, 2, 602, 347, 347, 347, 3, 12, 66, 46, 72, 80, 6, 2, 4]
               ]  ,)

           lowercase__									=    tokenizer.convert_ids_to_tokens(UpperCAmelCase_   )
           self.assertListEqual(
               UpperCAmelCase_  ,[
                   SPIECE_UNDERLINE + "I",
                   SPIECE_UNDERLINE + "was",
                   SPIECE_UNDERLINE + "b",
                   "or",
                   "n",
                   SPIECE_UNDERLINE + "in",
                   SPIECE_UNDERLINE + "",
                   "<unk>",
                   "2",
                   "0",
                   "0",
                   "0",
                   ",",
                   SPIECE_UNDERLINE + "and",
                   SPIECE_UNDERLINE + "this",
                   SPIECE_UNDERLINE + "is",
                   SPIECE_UNDERLINE + "f",
                   "al",
                   "s",
                   "<unk>",
                   ".",
               ]  ,)



       @cached_property
       def 				_a   (					self   )	->				Optional[int]:
           return XGLMTokenizer.from_pretrained("facebook/xglm-564M"   )



       def 				_a   (					self   )	->				int:
           with tempfile.NamedTemporaryFile() as f:
               shutil.copyfile(UpperCAmelCase_  ,f.name   )
               lowercase__									=    XGLMTokenizer(f.name  ,keep_accents=UpperCAmelCase_   )
               lowercase__									=    pickle.dumps(UpperCAmelCase_   )
           pickle.loads(UpperCAmelCase_   )



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

           lowercase__									=    self.get_tokenizer()
           lowercase__									=    self.get_rust_tokenizer()

           lowercase__									=    "I was born in 92000, and this is falsé."

           lowercase__									=    tokenizer.tokenize(UpperCAmelCase_   )
           lowercase__									=    rust_tokenizer.tokenize(UpperCAmelCase_   )
           self.assertListEqual(UpperCAmelCase_  ,UpperCAmelCase_   )

           lowercase__									=    tokenizer.encode(UpperCAmelCase_  ,add_special_tokens=UpperCAmelCase_   )
           lowercase__									=    rust_tokenizer.encode(UpperCAmelCase_  ,add_special_tokens=UpperCAmelCase_   )
           self.assertListEqual(UpperCAmelCase_  ,UpperCAmelCase_   )

           lowercase__									=    self.get_rust_tokenizer()
           lowercase__									=    tokenizer.encode(UpperCAmelCase_   )
           lowercase__									=    rust_tokenizer.encode(UpperCAmelCase_   )
           self.assertListEqual(UpperCAmelCase_  ,UpperCAmelCase_   )



       @slow
       def 				_a   (					self   )	->				List[str]:
           lowercase__									=    "Hello World!"
           lowercase__									=    [2, 31_227, 4_447, 35]

           self.assertListEqual(UpperCAmelCase_  ,self.big_tokenizer.encode(UpperCAmelCase_   )   )



       @slow
       def 				_a   (					self   )	->				str:
           lowercase__									=    (
               "This is a very long text with a lot of weird characters, such as: . , ~ ? ( ) \" [ ] ! : - . Also we will"
               " add words that should not exsist and be tokenized to unk, such as saoneuhaoesuth"
           )
           # fmt: off
           lowercase__									=    [2, 1_018, 67, 11, 1_988, 2_617, 5_631, 278, 11, 3_407, 48, 71_630, 28_085, 4, 3_234, 157, 13, 6, 5, 6, 4, 3_526, 768, 15, 659, 57, 298, 3_983, 864, 129, 21, 6, 5, 13_675, 377, 652, 7_580, 10_341, 155, 2_817, 422, 1_666, 7, 1_674, 53, 113, 202_277, 17_892, 33, 60, 87, 4, 3_234, 157, 61, 2_667, 52_376, 19, 88, 23, 735]
           # fmt: on

           self.assertListEqual(UpperCAmelCase_  ,self.big_tokenizer.encode(UpperCAmelCase_   )   )







       @slow
       def 				_a   (					self   )	->				str:
           # fmt: off
           lowercase__									=    {
               "input_ids": [[2, 108_825, 1_163, 15, 88_010, 473, 15_898, 157, 13_672, 1_857, 312, 8, 238_021, 1_163, 53, 13_672, 1_857, 312, 8, 53_283, 182_396, 8, 18_566, 16, 36_733, 4_101, 8, 230, 244_017, 122_553, 7, 15, 132_597, 4, 293, 12_511, 7_610, 4, 3_414, 132_597, 9, 4, 32_361, 362, 4, 734, 28_512, 32_569, 18, 4, 32_361, 26_096, 14_982, 73, 18_715, 21_433, 235_261, 15, 492, 12_427, 16, 53, 18_715, 21_433, 65_454, 15, 23_659, 563, 16, 278, 597, 2_843, 595, 7_931, 182_396, 64_186, 22, 886, 595, 132_981, 53, 25_540, 3_449, 43_982, 39_901, 5_951, 878, 330, 4, 27_694, 80_269, 312, 53, 6_517, 11_780, 611, 20_408, 5], [2, 6, 132_597, 67, 42_897, 33, 592, 8, 163_729, 25_540, 361, 136_997, 109_514, 173_230, 7, 501, 60, 102_913, 196, 5_631, 235, 63_243, 473, 6, 231_757, 74, 5_277, 7_905, 53, 3_095, 37_317, 22, 454, 183_874, 5], [2, 268, 31_298, 46_530, 6, 132_935, 43_831, 7, 597, 32, 24, 3_688, 9_865, 5]],
               "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, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
           }  # noqa: E501
           # fmt: on

           self.tokenizer_integration_test_util(
               expected_encoding=UpperCAmelCase_  ,model_name="facebook/xglm-564M"  ,padding=UpperCAmelCase_  ,)




