code: 
  import json
  import os
  from functools import lru_cache
  from typing import List, Optional, Tuple
  
  import regex as re
  
  from ...tokenization_utils import AddedToken, PreTrainedTokenizer
  from ...utils import logging
  
  
  SCREAMING_SNAKE_CASE_     				=   logging.get_logger(__name__)
  
  
  SCREAMING_SNAKE_CASE_     				=   {'vocab_file': 'vocab.json', 'merges_file': 'merges.txt'}
  
  # See all MVP models at https://huggingface.co/models?filter=mvp
  SCREAMING_SNAKE_CASE_     				=   {
      'vocab_file': {
          'RUCAIBox/mvp': 'https://huggingface.co/RUCAIBox/mvp/resolve/main/vocab.json',
      },
      'added_tokens.json': {
          'RUCAIBox/mvp': 'https://huggingface.co/RUCAIBox/mvp/resolve/main/added_tokens.json',
      },
      'merges_file': {
          'RUCAIBox/mvp': 'https://huggingface.co/RUCAIBox/mvp/resolve/main/merges.txt',
      },
  }
  
  SCREAMING_SNAKE_CASE_     				=   {
      'RUCAIBox/mvp': 1024,
  }
  @lru_cache()
  def 			__UpperCAmelCase		(		)     ->       Optional[int]:
     _UpperCAmelCase   	=					(
         list(range(ord("!"				)    ,  ord("~"				) + 1				)				) + list(range(ord("¡"				)    ,  ord("¬"				) + 1				)				) + list(range(ord("®"				)    ,  ord("ÿ"				) + 1				)				)
     )
     _UpperCAmelCase   	=					bs[:]
     _UpperCAmelCase   	=					0
     for b in range(2**8				):
        if b not in bs:
           bs.append(UpperCamelCase__				)
           cs.append(2**8 + n				)
           n += 1
     _UpperCAmelCase   	=					[chr(UpperCamelCase__				) for n in cs]
     return dict(zip(UpperCamelCase__    ,  UpperCamelCase__				)				)
  def 			__UpperCAmelCase		(		a_			:		List[str]				)     ->       List[str]:
     _UpperCAmelCase   	=					set()
     _UpperCAmelCase   	=					word[0]
     for char in word[1:]:
        pairs.add((prev_char, char)				)
        _UpperCAmelCase   	=					char
     return pairs
  
  
  
  
  
  
  class     __a			(					lowerCAmelCase_			):
         _lowerCamelCase							:							Optional[Any]       =			VOCAB_FILES_NAMES
         _lowerCamelCase							:							str       =			PRETRAINED_VOCAB_FILES_MAP
         _lowerCamelCase							:							Any       =			PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
         _lowerCamelCase							:							str       =			['input_ids', 'attention_mask']
  
  
  
  
  
  
  
         def __init__(					self							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_="replace"							,lowerCamelCase_="<s>"							,lowerCamelCase_="</s>"							,lowerCamelCase_="</s>"							,lowerCamelCase_="<s>"							,lowerCamelCase_="<unk>"							,lowerCamelCase_="<pad>"							,lowerCamelCase_="<mask>"							,lowerCamelCase_=False							,**lowerCamelCase_							,):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					AddedToken(lowerCamelCase_							,lstrip=lowerCamelCase_							,rstrip=lowerCamelCase_		) if isinstance(lowerCamelCase_							,lowerCamelCase_		) else bos_token
            _UpperCAmelCase   	=					AddedToken(lowerCamelCase_							,lstrip=lowerCamelCase_							,rstrip=lowerCamelCase_		) if isinstance(lowerCamelCase_							,lowerCamelCase_		) else eos_token
            _UpperCAmelCase   	=					AddedToken(lowerCamelCase_							,lstrip=lowerCamelCase_							,rstrip=lowerCamelCase_		) if isinstance(lowerCamelCase_							,lowerCamelCase_		) else sep_token
            _UpperCAmelCase   	=					AddedToken(lowerCamelCase_							,lstrip=lowerCamelCase_							,rstrip=lowerCamelCase_		) if isinstance(lowerCamelCase_							,lowerCamelCase_		) else cls_token
            _UpperCAmelCase   	=					AddedToken(lowerCamelCase_							,lstrip=lowerCamelCase_							,rstrip=lowerCamelCase_		) if isinstance(lowerCamelCase_							,lowerCamelCase_		) else unk_token
            _UpperCAmelCase   	=					AddedToken(lowerCamelCase_							,lstrip=lowerCamelCase_							,rstrip=lowerCamelCase_		) if isinstance(lowerCamelCase_							,lowerCamelCase_		) else pad_token
  
            # Mask token behave like a normal word, i.e. include the space before it
            _UpperCAmelCase   	=					AddedToken(lowerCamelCase_							,lstrip=lowerCamelCase_							,rstrip=lowerCamelCase_		) if isinstance(lowerCamelCase_							,lowerCamelCase_		) else mask_token
  
            super().__init__(
                errors=lowerCamelCase_							,bos_token=lowerCamelCase_							,eos_token=lowerCamelCase_							,unk_token=lowerCamelCase_							,sep_token=lowerCamelCase_							,cls_token=lowerCamelCase_							,pad_token=lowerCamelCase_							,mask_token=lowerCamelCase_							,add_prefix_space=lowerCamelCase_							,**lowerCamelCase_							,)
            with open(lowerCamelCase_							,encoding="utf-8"		) as vocab_handle:
               _UpperCAmelCase   	=					json.load(lowerCamelCase_		)
            _UpperCAmelCase   	=					{v: k for k, v in self.encoder.items()}
            _UpperCAmelCase   	=					errors  # how to handle errors in decoding
            _UpperCAmelCase   	=					bytes_to_unicode()
            _UpperCAmelCase   	=					{v: k for k, v in self.byte_encoder.items()}
            with open(lowerCamelCase_							,encoding="utf-8"		) as merges_handle:
               _UpperCAmelCase   	=					merges_handle.read().split("\n"		)[1:-1]
            _UpperCAmelCase   	=					[tuple(merge.split()		) for merge in bpe_merges]
            _UpperCAmelCase   	=					dict(zip(lowerCamelCase_							,range(len(lowerCamelCase_		)		)		)		)
            _UpperCAmelCase   	=					{}
            _UpperCAmelCase   	=					add_prefix_space
  
            # Should have added re.IGNORECASE so BPE merges can happen for capitalized versions of contractions
            _UpperCAmelCase   	=					re.compile(r"\'s|\'t|\'re|\'ve|\'m|\'ll|\'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+"		)
  
  
  
  
  
  
  
         @property
         def    _snake_case			(					self		):
  
  
  
            '''simple docstring'''
  
            return len(self.encoder		)
  
  
  
  
  
  
  
         def    _snake_case			(					self		):
  
  
  
            '''simple docstring'''
  
            return dict(self.encoder							,**self.added_tokens_encoder		)
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_		):
  
  
  
            '''simple docstring'''
  
            if token in self.cache:
               return self.cache[token]
            _UpperCAmelCase   	=					tuple(lowerCamelCase_		)
            _UpperCAmelCase   	=					get_pairs(lowerCamelCase_		)
  
            if not pairs:
               return token
  
            while True:
               _UpperCAmelCase   	=					min(lowerCamelCase_							,key=lambda lowerCamelCase_		: self.bpe_ranks.get(lowerCamelCase_							,float("inf"		)		)		)
               if bigram not in self.bpe_ranks:
                  break
               _UpperCAmelCase   	=					bigram
               _UpperCAmelCase   	=					[]
               _UpperCAmelCase   	=					0
               while i < len(lowerCamelCase_		):
                  try:
                     _UpperCAmelCase   	=					word.index(lowerCamelCase_							,lowerCamelCase_		)
                  except ValueError:
                     new_word.extend(word[i:]		)
                     break
                  else:
                     new_word.extend(word[i:j]		)
                     _UpperCAmelCase   	=					j
  
                  if word[i] == first and i < len(lowerCamelCase_		) - 1 and word[i + 1] == second:
                     new_word.append(first + second		)
                     i += 2
                  else:
                     new_word.append(word[i]		)
                     i += 1
               _UpperCAmelCase   	=					tuple(lowerCamelCase_		)
               _UpperCAmelCase   	=					new_word
               if len(lowerCamelCase_		) == 1:
                  break
               else:
                  _UpperCAmelCase   	=					get_pairs(lowerCamelCase_		)
            _UpperCAmelCase   	=					''' '''.join(lowerCamelCase_		)
            _UpperCAmelCase   	=					word
            return word
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					[]
            for token in re.findall(self.pat							,lowerCamelCase_		):
               _UpperCAmelCase   	=					''''''.join(
                   self.byte_encoder[b] for b in token.encode("utf-8"		)		)  # Maps all our bytes to unicode strings, avoiding control tokens of the BPE (spaces in our case)
               bpe_tokens.extend(bpe_token for bpe_token in self.bpe(lowerCamelCase_		).split(" "		)		)
            return bpe_tokens
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_		):
  
  
  
            '''simple docstring'''
  
            return self.encoder.get(lowerCamelCase_							,self.encoder.get(self.unk_token		)		)
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_		):
  
  
  
            '''simple docstring'''
  
            return self.decoder.get(lowerCamelCase_		)
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					''''''.join(lowerCamelCase_		)
            _UpperCAmelCase   	=					bytearray([self.byte_decoder[c] for c in text]		).decode("utf-8"							,errors=self.errors		)
            return text
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_							,lowerCamelCase_ = None		):
  
  
  
            '''simple docstring'''
  
            if not os.path.isdir(lowerCamelCase_		):
               logger.error(f'''Vocabulary path ({save_directory}) should be a directory'''		)
               return
            _UpperCAmelCase   	=					os.path.join(
                lowerCamelCase_							,(filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]		)
            _UpperCAmelCase   	=					os.path.join(
                lowerCamelCase_							,(filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["merges_file"]		)
  
            with open(lowerCamelCase_							,"w"							,encoding="utf-8"		) as f:
               f.write(json.dumps(self.encoder							,indent=2							,sort_keys=lowerCamelCase_							,ensure_ascii=lowerCamelCase_		) + "\n"		)
  
            _UpperCAmelCase   	=					0
            with open(lowerCamelCase_							,"w"							,encoding="utf-8"		) as writer:
               writer.write("#version: 0.2\n"		)
               for bpe_tokens, token_index in sorted(self.bpe_ranks.items()							,key=lambda lowerCamelCase_		: kv[1]		):
                  if index != token_index:
                     logger.warning(
                         f'''Saving vocabulary to {merge_file}: BPE merge indices are not consecutive.'''
                         " Please check that the tokenizer is not corrupted!"		)
                     _UpperCAmelCase   	=					token_index
                  writer.write(" ".join(lowerCamelCase_		) + "\n"		)
                  index += 1
  
            return vocab_file, merge_file
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_							,lowerCamelCase_ = None		):
  
  
  
            '''simple docstring'''
  
            if token_ids_a is None:
               return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
            _UpperCAmelCase   	=					[self.cls_token_id]
            _UpperCAmelCase   	=					[self.sep_token_id]
            return cls + token_ids_a + sep + sep + token_ids_a + sep
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_							,lowerCamelCase_ = None							,lowerCamelCase_ = False		):
  
  
  
            '''simple docstring'''
  
            if already_has_special_tokens:
               return super().get_special_tokens_mask(
                   token_ids_a=lowerCamelCase_							,token_ids_a=lowerCamelCase_							,already_has_special_tokens=lowerCamelCase_		)
  
            if token_ids_a is None:
               return [1] + ([0] * len(lowerCamelCase_		)) + [1]
            return [1] + ([0] * len(lowerCamelCase_		)) + [1, 1] + ([0] * len(lowerCamelCase_		)) + [1]
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_							,lowerCamelCase_ = None		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					[self.sep_token_id]
            _UpperCAmelCase   	=					[self.cls_token_id]
  
            if token_ids_a is None:
               return len(cls + token_ids_a + sep		) * [0]
            return len(cls + token_ids_a + sep + sep + token_ids_a + sep		) * [0]
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_							,lowerCamelCase_=False							,**lowerCamelCase_		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					kwargs.pop("add_prefix_space"							,self.add_prefix_space		)
            if (is_split_into_words or add_prefix_space) and (len(lowerCamelCase_		) > 0 and not text[0].isspace()):
               _UpperCAmelCase   	=					''' ''' + text
            return (text, kwargs)
  
  
style_context: 
  """simple docstring"""
  
  
  
  
  
  
  
  from __future__ import annotations
  
  import unittest
  
  from transformers import AlbertConfig, is_tf_available
  from transformers.models.auto import get_values
  from transformers.testing_utils import require_tf, slow
  
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
  from ...test_pipeline_mixin import PipelineTesterMixin
  
  
  if is_tf_available():
    import tensorflow as tf
  
    from transformers import TF_MODEL_FOR_PRETRAINING_MAPPING
    from transformers.models.albert.modeling_tf_albert import (
        TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFAlbertForMaskedLM,
        TFAlbertForMultipleChoice,
        TFAlbertForPreTraining,
        TFAlbertForQuestionAnswering,
        TFAlbertForSequenceClassification,
        TFAlbertForTokenClassification,
        TFAlbertModel,
    )
  
  
  
  
  
  
  class     __a			:
  
  
  
  
  
  
  
         def __init__(					self							,lowerCamelCase_							,lowerCamelCase_=13							,lowerCamelCase_=7							,lowerCamelCase_=True							,lowerCamelCase_=True							,lowerCamelCase_=True							,lowerCamelCase_=True							,lowerCamelCase_=99							,lowerCamelCase_=16							,lowerCamelCase_=32							,lowerCamelCase_=2							,lowerCamelCase_=4							,lowerCamelCase_=37							,lowerCamelCase_="gelu"							,lowerCamelCase_=0.1							,lowerCamelCase_=0.1							,lowerCamelCase_=512							,lowerCamelCase_=16							,lowerCamelCase_=2							,lowerCamelCase_=0.0_2							,lowerCamelCase_=3							,lowerCamelCase_=4							,lowerCamelCase_=None							,):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					parent
            _UpperCAmelCase   	=					13
            _UpperCAmelCase   	=					7
            _UpperCAmelCase   	=					True
            _UpperCAmelCase   	=					True
            _UpperCAmelCase   	=					True
            _UpperCAmelCase   	=					True
            _UpperCAmelCase   	=					99
            _UpperCAmelCase   	=					16
            _UpperCAmelCase   	=					32
            _UpperCAmelCase   	=					2
            _UpperCAmelCase   	=					4
            _UpperCAmelCase   	=					37
            _UpperCAmelCase   	=					"gelu"
            _UpperCAmelCase   	=					0.1
            _UpperCAmelCase   	=					0.1
            _UpperCAmelCase   	=					512
            _UpperCAmelCase   	=					16
            _UpperCAmelCase   	=					2
            _UpperCAmelCase   	=					0.0_2
            _UpperCAmelCase   	=					3
            _UpperCAmelCase   	=					4
            _UpperCAmelCase   	=					None
  
  
  
  
  
  
  
         def    _snake_case			(					self		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					ids_tensor([self.batch_size, self.seq_length]							,self.vocab_size		)
  
            _UpperCAmelCase   	=					None
            if self.use_input_mask:
               _UpperCAmelCase   	=					random_attention_mask([self.batch_size, self.seq_length]		)
  
            _UpperCAmelCase   	=					None
            if self.use_token_type_ids:
               _UpperCAmelCase   	=					ids_tensor([self.batch_size, self.seq_length]							,self.type_vocab_size		)
  
            _UpperCAmelCase   	=					None
            _UpperCAmelCase   	=					None
            _UpperCAmelCase   	=					None
            if self.use_labels:
               _UpperCAmelCase   	=					ids_tensor([self.batch_size]							,self.type_sequence_label_size		)
               _UpperCAmelCase   	=					ids_tensor([self.batch_size, self.seq_length]							,self.num_labels		)
               _UpperCAmelCase   	=					ids_tensor([self.batch_size]							,self.num_choices		)
  
            _UpperCAmelCase   	=					AlbertConfig(
                vocab_size=self.vocab_size							,hidden_size=self.hidden_size							,embedding_size=self.embedding_size							,num_hidden_layers=self.num_hidden_layers							,num_attention_heads=self.num_attention_heads							,intermediate_size=self.intermediate_size							,hidden_act=self.hidden_act							,hidden_dropout_prob=self.hidden_dropout_prob							,attention_probs_dropout_prob=self.attention_probs_dropout_prob							,max_position_embeddings=self.max_position_embeddings							,type_vocab_size=self.type_vocab_size							,initializer_range=self.initializer_range							,)
  
            return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					TFAlbertModel(config=lowerCamelCase_		)
            # inputs = {'input_ids': input_ids,
            #           'attention_mask': input_mask,
            #           'token_type_ids': token_type_ids}
            # sequence_output, pooled_output = model(**inputs)
            _UpperCAmelCase   	=					{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
            _UpperCAmelCase   	=					model(lowerCamelCase_		)
  
            _UpperCAmelCase   	=					[input_ids, input_mask]
            _UpperCAmelCase   	=					model(lowerCamelCase_		)
  
            _UpperCAmelCase   	=					model(lowerCamelCase_		)
  
            self.parent.assertEqual(result.last_hidden_state.shape							,(self.batch_size, self.seq_length, self.hidden_size)		)
            self.parent.assertEqual(result.pooler_output.shape							,(self.batch_size, self.hidden_size)		)
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					self.num_labels
            _UpperCAmelCase   	=					TFAlbertForPreTraining(config=lowerCamelCase_		)
            _UpperCAmelCase   	=					{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
            _UpperCAmelCase   	=					model(lowerCamelCase_		)
            self.parent.assertEqual(result.prediction_logits.shape							,(self.batch_size, self.seq_length, self.vocab_size)		)
            self.parent.assertEqual(result.sop_logits.shape							,(self.batch_size, self.num_labels)		)
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					TFAlbertForMaskedLM(config=lowerCamelCase_		)
            _UpperCAmelCase   	=					{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
            _UpperCAmelCase   	=					model(lowerCamelCase_		)
            self.parent.assertEqual(result.logits.shape							,(self.batch_size, self.seq_length, self.vocab_size)		)
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					self.num_labels
            _UpperCAmelCase   	=					TFAlbertForSequenceClassification(config=lowerCamelCase_		)
            _UpperCAmelCase   	=					{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
            _UpperCAmelCase   	=					model(lowerCamelCase_		)
            self.parent.assertEqual(result.logits.shape							,(self.batch_size, self.num_labels)		)
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					TFAlbertForQuestionAnswering(config=lowerCamelCase_		)
            _UpperCAmelCase   	=					{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
            _UpperCAmelCase   	=					model(lowerCamelCase_		)
            self.parent.assertEqual(result.start_logits.shape							,(self.batch_size, self.seq_length)		)
            self.parent.assertEqual(result.end_logits.shape							,(self.batch_size, self.seq_length)		)
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					self.num_choices
            _UpperCAmelCase   	=					TFAlbertForMultipleChoice(config=lowerCamelCase_		)
            _UpperCAmelCase   	=					tf.tile(tf.expand_dims(lowerCamelCase_							,1		)							,(1, self.num_choices, 1)		)
            _UpperCAmelCase   	=					tf.tile(tf.expand_dims(lowerCamelCase_							,1		)							,(1, self.num_choices, 1)		)
            _UpperCAmelCase   	=					tf.tile(tf.expand_dims(lowerCamelCase_							,1		)							,(1, self.num_choices, 1)		)
            _UpperCAmelCase   	=					{
                "input_ids": multiple_choice_inputs_ids,
                "attention_mask": multiple_choice_input_mask,
                "token_type_ids": multiple_choice_token_type_ids,
            }
            _UpperCAmelCase   	=					model(lowerCamelCase_		)
            self.parent.assertListEqual(list(result["logits"].shape		)							,[self.batch_size, self.num_choices]		)
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					self.num_labels
            _UpperCAmelCase   	=					TFAlbertForTokenClassification(config=lowerCamelCase_		)
            _UpperCAmelCase   	=					{
                "input_ids": input_ids,
                "attention_mask": input_mask,
                "token_type_ids": token_type_ids,
            }
            _UpperCAmelCase   	=					model(lowerCamelCase_		)
            self.parent.assertListEqual(list(result["logits"].shape		)							,[self.batch_size, self.seq_length, self.num_labels]		)
  
  
  
  
  
  
  
         def    _snake_case			(					self		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					self.prepare_config_and_inputs()
            (
                (
                _UpperCAmelCase
            )	,							(
                _UpperCAmelCase
            )	,							(
                _UpperCAmelCase
            )	,							(
                _UpperCAmelCase
            )	,							(
                _UpperCAmelCase
            )	,							(
                _UpperCAmelCase
            )	,							(
                _UpperCAmelCase
            )	,							
            )   	=					config_and_inputs
            _UpperCAmelCase   	=					{"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
            return config, inputs_dict
  
  
  
  
  
  
  @require_tf
  class     __a			(					lowerCAmelCase_				,	lowerCAmelCase_				,	unittest.TestCase			):
         _lowerCamelCase							:							Any       =			(
             (
                 TFAlbertModel,
                 TFAlbertForPreTraining,
                 TFAlbertForMaskedLM,
                 TFAlbertForSequenceClassification,
                 TFAlbertForQuestionAnswering,
                 TFAlbertForTokenClassification,
                 TFAlbertForMultipleChoice,
             )
             if is_tf_available()
             else ()
         )
         _lowerCamelCase							:							int       =			(
             {
                 'feature-extraction': TFAlbertModel,
                 'fill-mask': TFAlbertForMaskedLM,
                 'question-answering': TFAlbertForQuestionAnswering,
                 'text-classification': TFAlbertForSequenceClassification,
                 'token-classification': TFAlbertForTokenClassification,
                 'zero-shot': TFAlbertForSequenceClassification,
             }
             if is_tf_available()
             else {}
         )
         _lowerCamelCase							:							List[str]       =			False
         _lowerCamelCase							:							Optional[Any]       =			False
  
  
  
  
  
  
  
         def    _snake_case			(					self							,lowerCamelCase_							,lowerCamelCase_							,lowerCamelCase_=False		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					super()._prepare_for_class(lowerCamelCase_							,lowerCamelCase_							,return_labels=lowerCamelCase_		)
  
            if return_labels:
               if model_class in get_values(lowerCamelCase_		):
                  _UpperCAmelCase   	=					tf.zeros(self.model_tester.batch_size							,dtype=tf.intaa		)
  
            return inputs_dict
  
  
  
  
  
  
  
         def    _snake_case			(					self		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					TFAlbertModelTester(self		)
            _UpperCAmelCase   	=					ConfigTester(self							,config_class=lowerCamelCase_							,hidden_size=37		)
  
  
  
  
  
  
  
         def    _snake_case			(					self		):
  
  
  
            '''simple docstring'''
  
            self.config_tester.run_common_tests()
  
  
  
  
  
  
  
         def    _snake_case			(					self		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_albert_model(*lowerCamelCase_		)
  
  
  
  
  
  
  
         def    _snake_case			(					self		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_albert_for_pretraining(*lowerCamelCase_		)
  
  
  
  
  
  
  
         def    _snake_case			(					self		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_albert_for_masked_lm(*lowerCamelCase_		)
  
  
  
  
  
  
  
         def    _snake_case			(					self		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_albert_for_multiple_choice(*lowerCamelCase_		)
  
  
  
  
  
  
  
         def    _snake_case			(					self		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_albert_for_sequence_classification(*lowerCamelCase_		)
  
  
  
  
  
  
  
         def    _snake_case			(					self		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_albert_for_question_answering(*lowerCamelCase_		)
  
  
  
  
  
  
  
         @slow
         def    _snake_case			(					self		):
  
  
  
            '''simple docstring'''
  
            for model_name in TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               _UpperCAmelCase   	=					TFAlbertModel.from_pretrained(lowerCamelCase_		)
               self.assertIsNotNone(lowerCamelCase_		)
  
  
  
  
  
  
  @require_tf
  class     __a			(					unittest.TestCase			):
  
  
  
  
  
  
  
         @slow
         def    _snake_case			(					self		):
  
  
  
            '''simple docstring'''
  
            _UpperCAmelCase   	=					TFAlbertForPreTraining.from_pretrained("albert-base-v2"		)
            _UpperCAmelCase   	=					tf.constant([[0, 1, 2, 3, 4, 5]]		)
            _UpperCAmelCase   	=					model(lowerCamelCase_		)[0]
  
            _UpperCAmelCase   	=					[1, 6, 3_0000]
            self.assertEqual(output.shape							,lowerCamelCase_		)
  
            _UpperCAmelCase   	=					tf.constant(
                [
                    [
                        [4.5_9_5_6_6_8, 0.7_4_4_6_2_7_5_4, -1.8_1_8_1_4_7],
                        [4.5_9_5_4_3_4_7, 0.7_4_5_4_1_8_4, -1.8_1_8_8_2_5_8],
                        [4.5_9_5_4_9_0_5, 0.7_4_4_8_2_3_5, -1.8_1_8_2_3_1_6],
                    ]
                ]		)
            tf.debugging.assert_near(output[:, :3, :3]							,lowerCamelCase_							,atol=1e-4		)
  
  