
import posixpath
from pathlib import Path
from unittest.mock import patch

import pytest
from fsspec.implementations.local import AbstractFileSystem, LocalFileSystem, stringify_path
from fsspec.registry import _registry as _fsspec_registry






class     a_       (			a__							):



       """simple docstring"""
       __SCREAMING_SNAKE_CASE       :					Any						=  'mock'






       def __init__(		self				,       *_lowerCamelCase				,       _lowerCamelCase				,       **_lowerCamelCase   )					->str:
           super().__init__()
           SCREAMING_SNAKE_CASE				:				List[Any]				      = LocalFileSystem(*_lowerCamelCase				,       **_lowerCamelCase   )
           SCREAMING_SNAKE_CASE				:				Optional[int]				      = Path(_lowerCamelCase   ).resolve().as_posix() + '''/'''






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )					->List[str]:
           SCREAMING_SNAKE_CASE				:				str				      = posixpath.join(self.local_root_dir				,       self._strip_protocol(_lowerCamelCase   )   )
           return self._fs.mkdir(_lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )					->List[str]:
           SCREAMING_SNAKE_CASE				:				int				      = posixpath.join(self.local_root_dir				,       self._strip_protocol(_lowerCamelCase   )   )
           return self._fs.makedirs(_lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase   )					->Union[str, Any]:
           SCREAMING_SNAKE_CASE				:				List[str]				      = posixpath.join(self.local_root_dir				,       self._strip_protocol(_lowerCamelCase   )   )
           return self._fs.rmdir(_lowerCamelCase   )






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       _lowerCamelCase=True				,       *_lowerCamelCase				,       **_lowerCamelCase   )					->List[Any]:
           SCREAMING_SNAKE_CASE				:				Dict				      = posixpath.join(self.local_root_dir				,       self._strip_protocol(_lowerCamelCase   )   )
           SCREAMING_SNAKE_CASE				:				Union[str, Any]				      = self._fs.ls(_lowerCamelCase				,       detail=_lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )
           if detail:
               return [{**info, "name": info["name"][len(self.local_root_dir   ) :]} for info in out]
           else:
               return [name[len(self.local_root_dir   ) :] for name in out]






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )					->Dict:
           SCREAMING_SNAKE_CASE				:				str				      = posixpath.join(self.local_root_dir				,       self._strip_protocol(_lowerCamelCase   )   )
           SCREAMING_SNAKE_CASE				:				List[str]				      = dict(self._fs.info(_lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )   )
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = out['''name'''][len(self.local_root_dir   ) :]
           return out






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       _lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )					->str:
           SCREAMING_SNAKE_CASE				:				List[str]				      = posixpath.join(self.local_root_dir				,       self._strip_protocol(_lowerCamelCase   )   )
           SCREAMING_SNAKE_CASE				:				Dict				      = posixpath.join(self.local_root_dir				,       self._strip_protocol(_lowerCamelCase   )   )
           return self._fs.cp_file(_lowerCamelCase				,       _lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )					->Tuple:
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = posixpath.join(self.local_root_dir				,       self._strip_protocol(_lowerCamelCase   )   )
           return self._fs.rm_file(_lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )					->Optional[int]:
           SCREAMING_SNAKE_CASE				:				Tuple				      = posixpath.join(self.local_root_dir				,       self._strip_protocol(_lowerCamelCase   )   )
           return self._fs.rm(_lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )					->int:
           SCREAMING_SNAKE_CASE				:				List[str]				      = posixpath.join(self.local_root_dir				,       self._strip_protocol(_lowerCamelCase   )   )
           return self._fs._open(_lowerCamelCase				,       *_lowerCamelCase				,       **_lowerCamelCase   )






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase   )					->str:
           SCREAMING_SNAKE_CASE				:				List[Any]				      = posixpath.join(self.local_root_dir				,       self._strip_protocol(_lowerCamelCase   )   )
           return self._fs.created(_lowerCamelCase   )






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase   )					->Dict:
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = posixpath.join(self.local_root_dir				,       self._strip_protocol(_lowerCamelCase   )   )
           return self._fs.modified(_lowerCamelCase   )






       @classmethod
       def 	__lowerCAmelCase     (		cls				,       _lowerCamelCase   )					->Tuple:
           SCREAMING_SNAKE_CASE				:				Tuple				      = stringify_path(_lowerCamelCase   )
           if path.startswith('''mock://'''   ):
               SCREAMING_SNAKE_CASE				:				Optional[int]				      = path[7:]
           return path






class     a_       (			a__							):



       """simple docstring"""
       __SCREAMING_SNAKE_CASE       :					Dict						=  'tmp'
       __SCREAMING_SNAKE_CASE       :					Any						=  None






       def __init__(		self				,       *_lowerCamelCase				,       **_lowerCamelCase   )					->List[str]:
           assert self.tmp_dir is not None, "TmpDirFileSystem.tmp_dir is not set"
           super().__init__(*_lowerCamelCase				,       **_lowerCamelCase				,       local_root_dir=self.tmp_dir				,       auto_mkdir=_lowerCamelCase   )






       @classmethod
       def 	__lowerCAmelCase     (		cls				,       _lowerCamelCase   )					->int:
           SCREAMING_SNAKE_CASE				:				int				      = stringify_path(_lowerCamelCase   )
           if path.startswith('''tmp://'''   ):
               SCREAMING_SNAKE_CASE				:				Optional[int]				      = path[6:]
           return path







@pytest.fixture
def 				UpperCAmelCase_(    ):



    """simple docstring"""



    SCREAMING_SNAKE_CASE				:				Union[str, Any]				      = MockFileSystem
    SCREAMING_SNAKE_CASE				:				List[Any]				      = TmpDirFileSystem
    yield
    del _fsspec_registry["mock"]
    del _fsspec_registry["tmp"]







@pytest.fixture
def 				UpperCAmelCase_(    a__ ,						a__   ):



    """simple docstring"""



    SCREAMING_SNAKE_CASE				:				Union[str, Any]				      = tmp_path_factory.mktemp('''mockfs'''   )
    return MockFileSystem(local_root_dir=a__ ,						auto_mkdir=a__   )







@pytest.fixture
def 				UpperCAmelCase_(    a__ ,						a__   ):



    """simple docstring"""



    SCREAMING_SNAKE_CASE				:				Optional[Any]				      = tmp_path_factory.mktemp('''tmpfs'''   )
    with patch.object(a__ ,						'''tmp_dir''' ,						a__   ):
        yield TmpDirFileSystem()


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_       :



       """simple docstring"""






       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				,       )					->List[Any]:
           SCREAMING_SNAKE_CASE				:				int				      = parent
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = 13
           SCREAMING_SNAKE_CASE				:				int				      = 7
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = True
           SCREAMING_SNAKE_CASE				:				List[str]				      = True
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = True
           SCREAMING_SNAKE_CASE				:				Optional[int]				      = True
           SCREAMING_SNAKE_CASE				:				Union[str, Any]				      = 99
           SCREAMING_SNAKE_CASE				:				str				      = 16
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = 32
           SCREAMING_SNAKE_CASE				:				str				      = 2
           SCREAMING_SNAKE_CASE				:				Optional[int]				      = 4
           SCREAMING_SNAKE_CASE				:				int				      = 37
           SCREAMING_SNAKE_CASE				:				Any				      = '''gelu'''
           SCREAMING_SNAKE_CASE				:				str				      = 0.1
           SCREAMING_SNAKE_CASE				:				Dict				      = 0.1
           SCREAMING_SNAKE_CASE				:				Tuple				      = 512
           SCREAMING_SNAKE_CASE				:				Any				      = 16
           SCREAMING_SNAKE_CASE				:				str				      = 2
           SCREAMING_SNAKE_CASE				:				Optional[int]				      = 0.0_2
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = 3
           SCREAMING_SNAKE_CASE				:				Union[str, Any]				      = 4
           SCREAMING_SNAKE_CASE				:				Optional[int]				      = None






       def 	__lowerCAmelCase     (		self   )					->List[str]:
           SCREAMING_SNAKE_CASE				:				Tuple				      = ids_tensor([self.batch_size, self.seq_length]				,       self.vocab_size   )

           SCREAMING_SNAKE_CASE				:				Optional[int]				      = None
           if self.use_input_mask:
               SCREAMING_SNAKE_CASE				:				Optional[int]				      = random_attention_mask([self.batch_size, self.seq_length]   )

           SCREAMING_SNAKE_CASE				:				Dict				      = None
           if self.use_token_type_ids:
               SCREAMING_SNAKE_CASE				:				Dict				      = ids_tensor([self.batch_size, self.seq_length]				,       self.type_vocab_size   )

           SCREAMING_SNAKE_CASE				:				str				      = None
           SCREAMING_SNAKE_CASE				:				Any				      = None
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = None
           if self.use_labels:
               SCREAMING_SNAKE_CASE				:				str				      = ids_tensor([self.batch_size]				,       self.type_sequence_label_size   )
               SCREAMING_SNAKE_CASE				:				List[str]				      = ids_tensor([self.batch_size, self.seq_length]				,       self.num_labels   )
               SCREAMING_SNAKE_CASE				:				Tuple				      = ids_tensor([self.batch_size]				,       self.num_choices   )

           SCREAMING_SNAKE_CASE				:				List[Any]				      = 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 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase   )					->List[str]:
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = TFAlbertModel(config=_lowerCamelCase   )
           # inputs = {'input_ids': input_ids,
           #           'attention_mask': input_mask,
           #           'token_type_ids': token_type_ids}
           # sequence_output, pooled_output = model(**inputs)
           SCREAMING_SNAKE_CASE				:				Union[str, Any]				      = {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
           SCREAMING_SNAKE_CASE				:				Union[str, Any]				      = model(_lowerCamelCase   )

           SCREAMING_SNAKE_CASE				:				List[str]				      = [input_ids, input_mask]
           SCREAMING_SNAKE_CASE				:				List[str]				      = model(_lowerCamelCase   )

           SCREAMING_SNAKE_CASE				:				Any				      = 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 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase   )					->List[Any]:
           SCREAMING_SNAKE_CASE				:				str				      = self.num_labels
           SCREAMING_SNAKE_CASE				:				List[str]				      = TFAlbertForPreTraining(config=_lowerCamelCase   )
           SCREAMING_SNAKE_CASE				:				Any				      = {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
           SCREAMING_SNAKE_CASE				:				int				      = 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 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase   )					->str:
           SCREAMING_SNAKE_CASE				:				str				      = TFAlbertForMaskedLM(config=_lowerCamelCase   )
           SCREAMING_SNAKE_CASE				:				int				      = {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = model(_lowerCamelCase   )
           self.parent.assertEqual(result.logits.shape				,       (self.batch_size, self.seq_length, self.vocab_size)   )






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase   )					->int:
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = self.num_labels
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = TFAlbertForSequenceClassification(config=_lowerCamelCase   )
           SCREAMING_SNAKE_CASE				:				Union[str, Any]				      = {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
           SCREAMING_SNAKE_CASE				:				Tuple				      = model(_lowerCamelCase   )
           self.parent.assertEqual(result.logits.shape				,       (self.batch_size, self.num_labels)   )






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase   )					->Dict:
           SCREAMING_SNAKE_CASE				:				List[str]				      = TFAlbertForQuestionAnswering(config=_lowerCamelCase   )
           SCREAMING_SNAKE_CASE				:				Optional[int]				      = {'''input_ids''': input_ids, '''attention_mask''': input_mask, '''token_type_ids''': token_type_ids}
           SCREAMING_SNAKE_CASE				:				int				      = 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 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase   )					->Any:
           SCREAMING_SNAKE_CASE				:				List[Any]				      = self.num_choices
           SCREAMING_SNAKE_CASE				:				Any				      = TFAlbertForMultipleChoice(config=_lowerCamelCase   )
           SCREAMING_SNAKE_CASE				:				Tuple				      = tf.tile(tf.expand_dims(_lowerCamelCase				,       1   )				,       (1, self.num_choices, 1)   )
           SCREAMING_SNAKE_CASE				:				Tuple				      = tf.tile(tf.expand_dims(_lowerCamelCase				,       1   )				,       (1, self.num_choices, 1)   )
           SCREAMING_SNAKE_CASE				:				Union[str, Any]				      = tf.tile(tf.expand_dims(_lowerCamelCase				,       1   )				,       (1, self.num_choices, 1)   )
           SCREAMING_SNAKE_CASE				:				Tuple				      = {
               '''input_ids''': multiple_choice_inputs_ids,
               '''attention_mask''': multiple_choice_input_mask,
               '''token_type_ids''': multiple_choice_token_type_ids,
           }
           SCREAMING_SNAKE_CASE				:				str				      = model(_lowerCamelCase   )
           self.parent.assertListEqual(list(result['''logits'''].shape   )				,       [self.batch_size, self.num_choices]   )






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase   )					->Optional[Any]:
           SCREAMING_SNAKE_CASE				:				str				      = self.num_labels
           SCREAMING_SNAKE_CASE				:				List[Any]				      = TFAlbertForTokenClassification(config=_lowerCamelCase   )
           SCREAMING_SNAKE_CASE				:				Optional[int]				      = {
               '''input_ids''': input_ids,
               '''attention_mask''': input_mask,
               '''token_type_ids''': token_type_ids,
           }
           SCREAMING_SNAKE_CASE				:				str				      = model(_lowerCamelCase   )
           self.parent.assertListEqual(list(result['''logits'''].shape   )				,       [self.batch_size, self.seq_length, self.num_labels]   )






       def 	__lowerCAmelCase     (		self   )					->List[Any]:
           SCREAMING_SNAKE_CASE				:				List[Any]				      = self.prepare_config_and_inputs()
           (
               (
               SCREAMING_SNAKE_CASE
           )      ,							(
               SCREAMING_SNAKE_CASE
           )      ,							(
               SCREAMING_SNAKE_CASE
           )      ,							(
               SCREAMING_SNAKE_CASE
           )      ,							(
               SCREAMING_SNAKE_CASE
           )      ,							(
               SCREAMING_SNAKE_CASE
           )      ,							(
               SCREAMING_SNAKE_CASE
           )      ,							
           )				:				Any				      = config_and_inputs
           SCREAMING_SNAKE_CASE				:				Optional[int]				      = {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
           return config, inputs_dict






@require_tf
class     a_       (			a__				,    a__				,    unittest.TestCase							):



       """simple docstring"""
       __SCREAMING_SNAKE_CASE       :					int						=  (
           (
               TFAlbertModel,
               TFAlbertForPreTraining,
               TFAlbertForMaskedLM,
               TFAlbertForSequenceClassification,
               TFAlbertForQuestionAnswering,
               TFAlbertForTokenClassification,
               TFAlbertForMultipleChoice,
           )
           if is_tf_available()
           else ()
       )
       __SCREAMING_SNAKE_CASE       :					Optional[int]						=  (
           {
               'feature-extraction': TFAlbertModel,
               'fill-mask': TFAlbertForMaskedLM,
               'question-answering': TFAlbertForQuestionAnswering,
               'text-classification': TFAlbertForSequenceClassification,
               'token-classification': TFAlbertForTokenClassification,
               'zero-shot': TFAlbertForSequenceClassification,
           }
           if is_tf_available()
           else {}
       )
       __SCREAMING_SNAKE_CASE       :					Tuple						=  False
       __SCREAMING_SNAKE_CASE       :					Any						=  False






       def 	__lowerCAmelCase     (		self				,       _lowerCamelCase				,       _lowerCamelCase				,       _lowerCamelCase=False   )					->int:
           SCREAMING_SNAKE_CASE				:				Tuple				      = super()._prepare_for_class(_lowerCamelCase				,       _lowerCamelCase				,       return_labels=_lowerCamelCase   )

           if return_labels:
               if model_class in get_values(_lowerCamelCase   ):
                   SCREAMING_SNAKE_CASE				:				Union[str, Any]				      = tf.zeros(self.model_tester.batch_size				,       dtype=tf.intaa   )

           return inputs_dict






       def 	__lowerCAmelCase     (		self   )					->Tuple:
           SCREAMING_SNAKE_CASE				:				Dict				      = TFAlbertModelTester(self   )
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = ConfigTester(self				,       config_class=_lowerCamelCase				,       hidden_size=37   )






       def 	__lowerCAmelCase     (		self   )					->Union[str, Any]:
           self.config_tester.run_common_tests()






       def 	__lowerCAmelCase     (		self   )					->str:
           SCREAMING_SNAKE_CASE				:				Tuple				      = self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_albert_model(*_lowerCamelCase   )






       def 	__lowerCAmelCase     (		self   )					->str:
           SCREAMING_SNAKE_CASE				:				Optional[Any]				      = self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_albert_for_pretraining(*_lowerCamelCase   )






       def 	__lowerCAmelCase     (		self   )					->Any:
           SCREAMING_SNAKE_CASE				:				Dict				      = self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_albert_for_masked_lm(*_lowerCamelCase   )






       def 	__lowerCAmelCase     (		self   )					->Optional[Any]:
           SCREAMING_SNAKE_CASE				:				List[str]				      = self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_albert_for_multiple_choice(*_lowerCamelCase   )






       def 	__lowerCAmelCase     (		self   )					->Dict:
           SCREAMING_SNAKE_CASE				:				List[Any]				      = self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_albert_for_sequence_classification(*_lowerCamelCase   )






       def 	__lowerCAmelCase     (		self   )					->str:
           SCREAMING_SNAKE_CASE				:				Optional[int]				      = self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_albert_for_question_answering(*_lowerCamelCase   )






       @slow
       def 	__lowerCAmelCase     (		self   )					->int:
           for model_name in TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               SCREAMING_SNAKE_CASE				:				Tuple				      = TFAlbertModel.from_pretrained(_lowerCamelCase   )
               self.assertIsNotNone(_lowerCamelCase   )






@require_tf
class     a_       (			unittest.TestCase							):



       """simple docstring"""






       @slow
       def 	__lowerCAmelCase     (		self   )					->List[Any]:
           SCREAMING_SNAKE_CASE				:				Dict				      = TFAlbertForPreTraining.from_pretrained('''albert-base-v2'''   )
           SCREAMING_SNAKE_CASE				:				str				      = tf.constant([[0, 1, 2, 3, 4, 5]]   )
           SCREAMING_SNAKE_CASE				:				Union[str, Any]				      = model(_lowerCamelCase   )[0]

           SCREAMING_SNAKE_CASE				:				List[str]				      = [1, 6, 3_0000]
           self.assertEqual(output.shape				,       _lowerCamelCase   )

           SCREAMING_SNAKE_CASE				:				Dict				      = 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   )
