

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


snake_case_	    =			get_tests_dir('fixtures/test_sentencepiece.model')


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

snake_case_	    =			2_5_0_0_0_4
snake_case_	    =			2_5_0_0_2_0
@require_sentencepiece
@require_tokenizers
class       SCREAMING_SNAKE_CASE__     (							lowerCAmelCase_,unittest.TestCase ):
    _A            =				MBartTokenizer
    _A            =				MBartTokenizerFast
    _A            =				True
    _A            =				True




    def     __lowerCamelCase (   self     ):






          """simple docstring"""






          super().setUp()

          # We have a SentencePiece fixture for testing
          SCREAMING_SNAKE_CASE_ :     List[str]	=			MBartTokenizer(__lowerCamelCase							,	keep_accents=__lowerCamelCase     )
          tokenizer.save_pretrained(self.tmpdirname     )




    def     __lowerCamelCase (   self     ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_ :     str	=			MBartTokenizer(__lowerCamelCase							,	keep_accents=__lowerCamelCase     )

          SCREAMING_SNAKE_CASE_ :     Any	=			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]]							,	)

          SCREAMING_SNAKE_CASE_ :     Optional[Any]	=			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",
                  "é",
                  ".",
              ]							,	)
          SCREAMING_SNAKE_CASE_ :     Union[str, Any]	=			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 ^
              ]							,	)

          SCREAMING_SNAKE_CASE_ :     int	=			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     __lowerCamelCase (   self     ):






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

          SCREAMING_SNAKE_CASE_ :     Tuple	=			(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})"     ):
                      SCREAMING_SNAKE_CASE_ :     int	=			self.rust_tokenizer_class.from_pretrained(__lowerCamelCase							,	**__lowerCamelCase     )
                      SCREAMING_SNAKE_CASE_ :     str	=			self.tokenizer_class.from_pretrained(__lowerCamelCase							,	**__lowerCamelCase     )

                      SCREAMING_SNAKE_CASE_ :     Any	=			tempfile.mkdtemp()

                      SCREAMING_SNAKE_CASE_ :     Dict	=			tokenizer_r.save_pretrained(__lowerCamelCase     )
                      SCREAMING_SNAKE_CASE_ :     List[Any]	=			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     )     )
                      SCREAMING_SNAKE_CASE_ :     Dict	=			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
                      SCREAMING_SNAKE_CASE_ :     Tuple	=			tokenizer_r.from_pretrained(__lowerCamelCase     )
                      SCREAMING_SNAKE_CASE_ :     Union[str, Any]	=			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
                      SCREAMING_SNAKE_CASE_ :     Any	=			tempfile.mkdtemp()

                      SCREAMING_SNAKE_CASE_ :     Optional[Any]	=			tokenizer_r.save_pretrained(__lowerCamelCase							,	legacy_format=__lowerCamelCase     )
                      SCREAMING_SNAKE_CASE_ :     Optional[int]	=			tokenizer_p.save_pretrained(__lowerCamelCase     )

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

                      # Checks everything loads correctly in the same way
                      SCREAMING_SNAKE_CASE_ :     int	=			tokenizer_r.from_pretrained(__lowerCamelCase     )
                      SCREAMING_SNAKE_CASE_ :     List[Any]	=			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
                      SCREAMING_SNAKE_CASE_ :     List[Any]	=			tempfile.mkdtemp()

                      SCREAMING_SNAKE_CASE_ :     Any	=			tokenizer_r.save_pretrained(__lowerCamelCase							,	legacy_format=__lowerCamelCase     )
                      SCREAMING_SNAKE_CASE_ :     Any	=			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
                      SCREAMING_SNAKE_CASE_ :     Optional[int]	=			tokenizer_r.from_pretrained(__lowerCamelCase     )
                      SCREAMING_SNAKE_CASE_ :     List[str]	=			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       SCREAMING_SNAKE_CASE__     (							unittest.TestCase ):
    _A            =				"facebook/mbart-large-en-ro"
    _A            =				[
        " 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.",
    ]
    _A            =				[
        "Ş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.",
    ]
    _A            =				[8_274, 127_873, 25_916, 7, 8_622, 2_071, 438, 67_485, 53, 187_895, 23, 51_712, 2, EN_CODE]




    @classmethod
    def     __lowerCamelCase (   cls     ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_ :     MBartTokenizer	=			MBartTokenizer.from_pretrained(
              cls.checkpoint_name							,	src_lang="en_XX"							,	tgt_lang="ro_RO"     )
          SCREAMING_SNAKE_CASE_ :     Optional[int]	=			1
          return cls




    def     __lowerCamelCase (   self     ):






          """simple docstring"""






          self.assertEqual(self.tokenizer.fairseq_tokens_to_ids["ar_AR"]							,	25_0001     )
          self.assertEqual(self.tokenizer.fairseq_tokens_to_ids["en_EN"]							,	25_0004     )
          self.assertEqual(self.tokenizer.fairseq_tokens_to_ids["ro_RO"]							,	25_0020     )




    def     __lowerCamelCase (   self     ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_ :     str	=			self.tokenizer.batch_encode_plus(self.src_text     ).input_ids[0]
          self.assertListEqual(self.expected_src_tokens							,	__lowerCamelCase     )




    def     __lowerCamelCase (   self     ):






          """simple docstring"""






          self.assertIn(__lowerCamelCase							,	self.tokenizer.all_special_ids     )
          SCREAMING_SNAKE_CASE_ :     Union[str, Any]	=			[RO_CODE, 884, 9019, 96, 9, 916, 8_6792, 36, 1_8743, 1_5596, 5, 2]
          SCREAMING_SNAKE_CASE_ :     Union[str, Any]	=			self.tokenizer.decode(__lowerCamelCase							,	skip_special_tokens=__lowerCamelCase     )
          SCREAMING_SNAKE_CASE_ :     Optional[Any]	=			self.tokenizer.decode(generated_ids[1:]							,	skip_special_tokens=__lowerCamelCase     )
          self.assertEqual(__lowerCamelCase							,	__lowerCamelCase     )
          self.assertNotIn(self.tokenizer.eos_token							,	__lowerCamelCase     )




    def     __lowerCamelCase (   self     ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_ :     Tuple	=			['this is gunna be a long sentence ' * 20]
          assert isinstance(src_text[0]							,	__lowerCamelCase     )
          SCREAMING_SNAKE_CASE_ :     int	=			10
          SCREAMING_SNAKE_CASE_ :     List[str]	=			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     __lowerCamelCase (   self     ):






          """simple docstring"""






          self.assertListEqual(self.tokenizer.convert_tokens_to_ids(["<mask>", "ar_AR"]     )							,	[25_0026, 25_0001]     )




    def     __lowerCamelCase (   self     ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_ :     Any	=			tempfile.mkdtemp()
          SCREAMING_SNAKE_CASE_ :     List[Any]	=			self.tokenizer.fairseq_tokens_to_ids
          self.tokenizer.save_pretrained(__lowerCamelCase     )
          SCREAMING_SNAKE_CASE_ :     Union[str, Any]	=			MBartTokenizer.from_pretrained(__lowerCamelCase     )
          self.assertDictEqual(new_tok.fairseq_tokens_to_ids							,	__lowerCamelCase     )




    @require_torch
    def     __lowerCamelCase (   self     ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_ :     Optional[Any]	=			self.tokenizer(self.src_text							,	text_target=self.tgt_text							,	padding=__lowerCamelCase							,	return_tensors="pt"     )
          SCREAMING_SNAKE_CASE_ :     Any	=			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     __lowerCamelCase (   self     ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_ :     Tuple	=			self.tokenizer(
              self.src_text							,	text_target=self.tgt_text							,	padding=__lowerCamelCase							,	truncation=__lowerCamelCase							,	max_length=len(self.expected_src_tokens     )							,	return_tensors="pt"							,	)

          SCREAMING_SNAKE_CASE_ :     Tuple	=			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     )
          SCREAMING_SNAKE_CASE_ :     int	=			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     __lowerCamelCase (   self     ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_ :     Tuple	=			self.tokenizer(self.src_text							,	padding=__lowerCamelCase							,	truncation=__lowerCamelCase							,	max_length=3							,	return_tensors="pt"     )
          SCREAMING_SNAKE_CASE_ :     List[Any]	=			self.tokenizer(
              text_target=self.tgt_text							,	padding=__lowerCamelCase							,	truncation=__lowerCamelCase							,	max_length=10							,	return_tensors="pt"     )
          SCREAMING_SNAKE_CASE_ :     Optional[Any]	=			targets['input_ids']
          SCREAMING_SNAKE_CASE_ :     Tuple	=			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     __lowerCamelCase (   self     ):






          """simple docstring"""






          SCREAMING_SNAKE_CASE_ :     List[str]	=			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, 25_0004]],
                  "attention_mask": [[1, 1, 1, 1]],
                  # ar_AR
                  "forced_bos_token_id": 25_0001,
              }							,	)







'''simple docstring'''






import os
import re
import shutil
import sys
import tempfile
import unittest

import black


A_			      =		os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, "utils"))

import check_copies  # noqa: E402


# This is the reference code that will be used in the tests.
# If BertLMPredictionHead is changed in modeling_bert.py, this code needs to be manually updated.
A_			      =		"    def __init__(self, config):\n        super().__init__()\n        self.transform = BertPredictionHeadTransform(config)\n\n        # The output weights are the same as the input embeddings, but there is\n        # an output-only bias for each token.\n        self.decoder = nn.Linear(config.hidden_size, config.vocab_size, bias=False)\n\n        self.bias = nn.Parameter(torch.zeros(config.vocab_size))\n\n        # Need a link between the two variables so that the bias is correctly resized with `resize_token_embeddings`\n        self.decoder.bias = self.bias\n\n    def forward(self, hidden_states):\n        hidden_states = self.transform(hidden_states)\n        hidden_states = self.decoder(hidden_states)\n        return hidden_states\n"






class        lowercase_      (						unittest.TestCase							):





     def 			_lowerCAmelCase      (     self     :					Union[str, Any]			):
           snake_case__       :   str	      =    tempfile.mkdtemp()
           os.makedirs(os.path.join(self.transformer_dir     ,							'models/bert/'			)			)
           snake_case__       :   Optional[Any]	      =    self.transformer_dir
           shutil.copy(
               os.path.join(__lowerCamelCase     ,							'src/transformers/models/bert/modeling_bert.py'			)     ,							os.path.join(self.transformer_dir     ,							'models/bert/modeling_bert.py'			)     ,							)





     def 			_lowerCAmelCase      (     self     :					int			):
           snake_case__       :   Union[str, Any]	      =    'src/transformers'
           shutil.rmtree(self.transformer_dir			)





     def 			_lowerCAmelCase      (     self     :					Tuple     ,							__lowerCamelCase     :					Tuple     ,							__lowerCamelCase     :					Dict     ,							__lowerCamelCase     :					Tuple     ,							__lowerCamelCase     :					List[Any]=None			):
           snake_case__       :   Optional[int]	      =    comment + F"\nclass {class_name}(nn.Module):\n" + class_code
           if overwrite_result is not None:
                 snake_case__       :   List[Any]	      =    comment + F"\nclass {class_name}(nn.Module):\n" + overwrite_result
           snake_case__       :   Optional[int]	      =    black.Mode(target_versions={black.TargetVersion.PYaa}     ,							line_length=119			)
           snake_case__       :   Tuple	      =    black.format_str(__lowerCamelCase     ,							mode=__lowerCamelCase			)
           snake_case__       :   Union[str, Any]	      =    os.path.join(self.transformer_dir     ,							'new_code.py'			)
           with open(__lowerCamelCase     ,							'w'     ,							newline='\n'			) as f:
                 f.write(__lowerCamelCase			)
           if overwrite_result is None:
                 self.assertTrue(len(check_copies.is_copy_consistent(__lowerCamelCase			)			) == 0			)
           else:
                 check_copies.is_copy_consistent(f.name     ,							overwrite=__lowerCamelCase			)
                 with open(__lowerCamelCase     ,							'r'			) as f:
                       self.assertTrue(f.read()     ,							__lowerCamelCase			)





     def 			_lowerCAmelCase      (     self     :					Tuple			):
           snake_case__       :   List[str]	      =    check_copies.find_code_in_transformers('models.bert.modeling_bert.BertLMPredictionHead'			)
           self.assertEqual(__lowerCamelCase     ,							__lowerCamelCase			)





     def 			_lowerCAmelCase      (     self     :					Any			):
           # Base copy consistency
           self.check_copy_consistency(
               '# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead'     ,							'BertLMPredictionHead'     ,							REFERENCE_CODE + '\n'     ,							)

           # With no empty line at the end
           self.check_copy_consistency(
               '# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead'     ,							'BertLMPredictionHead'     ,							__lowerCamelCase     ,							)

           # Copy consistency with rename
           self.check_copy_consistency(
               '# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead with Bert->TestModel'     ,							'TestModelLMPredictionHead'     ,							re.sub('Bert'     ,							'TestModel'     ,							__lowerCamelCase			)     ,							)

           # Copy consistency with a really long name
           snake_case__       :   Union[str, Any]	      =    'TestModelWithAReallyLongNameBecauseSomePeopleLikeThatForSomeReason'
           self.check_copy_consistency(
               F"# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead with Bert->{long_class_name}"     ,							F"{long_class_name}LMPredictionHead"     ,							re.sub('Bert'     ,							__lowerCamelCase     ,							__lowerCamelCase			)     ,							)

           # Copy consistency with overwrite
           self.check_copy_consistency(
               '# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead with Bert->TestModel'     ,							'TestModelLMPredictionHead'     ,							__lowerCamelCase     ,							overwrite_result=re.sub('Bert'     ,							'TestModel'     ,							__lowerCamelCase			)     ,							)





     def 			_lowerCAmelCase      (     self     :					Union[str, Any]			):
           snake_case__       :   List[str]	      =    check_copies.LOCALIZED_READMES['README_zh-hans.md']

           snake_case__       :   List[str]	      =    (
               '1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (from Google Research and the'
               ' Toyota Technological Institute at Chicago) released with the paper [ALBERT: A Lite BERT for'
               ' Self-supervised Learning of Language Representations](https://arxiv.org/abs/1909.11942), by Zhenzhong'
               ' Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut.\n1.'
               ' **[DistilBERT](https://huggingface.co/transformers/model_doc/distilbert.html)** (from HuggingFace),'
               ' released together with the paper [DistilBERT, a distilled version of BERT: smaller, faster, cheaper and'
               ' lighter](https://arxiv.org/abs/1910.01108) by Victor Sanh, Lysandre Debut and Thomas Wolf. The same'
               ' method has been applied to compress GPT2 into'
               ' [DistilGPT2](https://github.com/huggingface/transformers/tree/main/examples/distillation), RoBERTa into'
               ' [DistilRoBERTa](https://github.com/huggingface/transformers/tree/main/examples/distillation),'
               ' Multilingual BERT into'
               ' [DistilmBERT](https://github.com/huggingface/transformers/tree/main/examples/distillation) and a German'
               ' version of DistilBERT.\n1. **[ELECTRA](https://huggingface.co/transformers/model_doc/electra.html)**'
               ' (from Google Research/Stanford University) released with the paper [ELECTRA: Pre-training text encoders'
               ' as discriminators rather than generators](https://arxiv.org/abs/2003.10555) by Kevin Clark, Minh-Thang'
               ' Luong, Quoc V. Le, Christopher D. Manning.'
           )
           snake_case__       :   Union[str, Any]	      =    (
               '1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (来自 Google Research and the'
               ' Toyota Technological Institute at Chicago) 伴随论文 [ALBERT: A Lite BERT for Self-supervised Learning of'
               ' Language Representations](https://arxiv.org/abs/1909.11942), 由 Zhenzhong Lan, Mingda Chen, Sebastian'
               ' Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut 发布。\n'
           )
           snake_case__       :   Tuple	      =    (
               '1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (来自 Google Research and the'
               ' Toyota Technological Institute at Chicago) 伴随论文 [ALBERT: A Lite BERT for Self-supervised Learning of'
               ' Language Representations](https://arxiv.org/abs/1909.11942), 由 Zhenzhong Lan, Mingda Chen, Sebastian'
               ' Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut 发布。\n1.'
               ' **[DistilBERT](https://huggingface.co/transformers/model_doc/distilbert.html)** (来自 HuggingFace) 伴随论文'
               ' [DistilBERT, a distilled version of BERT: smaller, faster, cheaper and'
               ' lighter](https://arxiv.org/abs/1910.01108) 由 Victor Sanh, Lysandre Debut and Thomas Wolf 发布。 The same'
               ' method has been applied to compress GPT2 into'
               ' [DistilGPT2](https://github.com/huggingface/transformers/tree/main/examples/distillation), RoBERTa into'
               ' [DistilRoBERTa](https://github.com/huggingface/transformers/tree/main/examples/distillation),'
               ' Multilingual BERT into'
               ' [DistilmBERT](https://github.com/huggingface/transformers/tree/main/examples/distillation) and a German'
               ' version of DistilBERT.\n1. **[ELECTRA](https://huggingface.co/transformers/model_doc/electra.html)** (来自'
               ' Google Research/Stanford University) 伴随论文 [ELECTRA: Pre-training text encoders as discriminators rather'
               ' than generators](https://arxiv.org/abs/2003.10555) 由 Kevin Clark, Minh-Thang Luong, Quoc V. Le,'
               ' Christopher D. Manning 发布。\n'
           )

           snake_case__      ,							snake_case__       :   Optional[Any]	      =    check_copies.convert_to_localized_md(
               __lowerCamelCase     ,							__lowerCamelCase     ,							localized_readme['format_model_list']			)

           self.assertFalse(__lowerCamelCase			)
           self.assertEqual(__lowerCamelCase     ,							__lowerCamelCase			)

           snake_case__      ,							snake_case__       :   Any	      =    check_copies.convert_to_localized_md(
               __lowerCamelCase     ,							__lowerCamelCase     ,							localized_readme['format_model_list']			)

           # Check whether the number of models is equal to README.md after conversion.
           self.assertTrue(__lowerCamelCase			)

           snake_case__       :   Optional[Any]	      =    (
               '1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (from Google Research and the'
               ' Toyota Technological Institute at Chicago) released with the paper [ALBERT: A Lite BERT for'
               ' Self-supervised Learning of Language Representations](https://arxiv.org/abs/1909.11942), by Zhenzhong'
               ' Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut.'
           )
           snake_case__       :   int	      =    (
               '1. **[ALBERT](https://huggingface.co/transformers/main/model_doc/albert.html)** (来自 Google Research and'
               ' the Toyota Technological Institute at Chicago) 伴随论文 [ALBERT: A Lite BERT for Self-supervised Learning of'
               ' Language Representations](https://arxiv.org/abs/1909.11942), 由 Zhenzhong Lan, Mingda Chen, Sebastian'
               ' Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut 发布。\n'
           )
           snake_case__       :   List[str]	      =    (
               '1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (来自 Google Research and the'
               ' Toyota Technological Institute at Chicago) 伴随论文 [ALBERT: A Lite BERT for Self-supervised Learning of'
               ' Language Representations](https://arxiv.org/abs/1909.11942), 由 Zhenzhong Lan, Mingda Chen, Sebastian'
               ' Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut 发布。\n'
           )

           snake_case__      ,							snake_case__       :   Any	      =    check_copies.convert_to_localized_md(
               __lowerCamelCase     ,							__lowerCamelCase     ,							localized_readme['format_model_list']			)

           # Check if the model link is synchronized.
           self.assertEqual(__lowerCamelCase     ,							__lowerCamelCase			)
