code: 
  
  
  
  
  """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 							lowerCamelCase		:
  
  
  
  
  
  
  
     def __init__(							self    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_=13    ,      SCREAMING_SNAKE_CASE_=7    ,      SCREAMING_SNAKE_CASE_=True    ,      SCREAMING_SNAKE_CASE_=True    ,      SCREAMING_SNAKE_CASE_=True    ,      SCREAMING_SNAKE_CASE_=True    ,      SCREAMING_SNAKE_CASE_=99    ,      SCREAMING_SNAKE_CASE_=16    ,      SCREAMING_SNAKE_CASE_=32    ,      SCREAMING_SNAKE_CASE_=2    ,      SCREAMING_SNAKE_CASE_=4    ,      SCREAMING_SNAKE_CASE_=37    ,      SCREAMING_SNAKE_CASE_="gelu"    ,      SCREAMING_SNAKE_CASE_=0.1    ,      SCREAMING_SNAKE_CASE_=0.1    ,      SCREAMING_SNAKE_CASE_=512    ,      SCREAMING_SNAKE_CASE_=16    ,      SCREAMING_SNAKE_CASE_=2    ,      SCREAMING_SNAKE_CASE_=0.02    ,      SCREAMING_SNAKE_CASE_=3    ,      SCREAMING_SNAKE_CASE_=4    ,      SCREAMING_SNAKE_CASE_=None    ,      ):
         UpperCamelCase				:   Any          =							parent
         UpperCamelCase				:   Optional[int]          =							13
         UpperCamelCase				:   List[str]          =							7
         UpperCamelCase				:   Union[str, Any]          =							True
         UpperCamelCase				:   Optional[Any]          =							True
         UpperCamelCase				:   Any          =							True
         UpperCamelCase				:   Tuple          =							True
         UpperCamelCase				:   Optional[int]          =							99
         UpperCamelCase				:   Union[str, Any]          =							16
         UpperCamelCase				:   Optional[int]          =							32
         UpperCamelCase				:   List[Any]          =							2
         UpperCamelCase				:   List[str]          =							4
         UpperCamelCase				:   Dict          =							37
         UpperCamelCase				:   Dict          =							"""gelu"""
         UpperCamelCase				:   Union[str, Any]          =							0.1
         UpperCamelCase				:   List[Any]          =							0.1
         UpperCamelCase				:   List[str]          =							512
         UpperCamelCase				:   Any          =							16
         UpperCamelCase				:   Optional[Any]          =							2
         UpperCamelCase				:   Tuple          =							0.02
         UpperCamelCase				:   Optional[Any]          =							3
         UpperCamelCase				:   Optional[int]          =							4
         UpperCamelCase				:   Optional[Any]          =							None
  
  
  
  
  
  
  
     def       a_							(							self ):
         UpperCamelCase				:   Any          =							ids_tensor([self.batch_size, self.seq_length]    ,      self.vocab_size )
  
         UpperCamelCase				:   Union[str, Any]          =							None
         if self.use_input_mask:
             UpperCamelCase				:   List[Any]          =							random_attention_mask([self.batch_size, self.seq_length] )
  
         UpperCamelCase				:   Optional[int]          =							None
         if self.use_token_type_ids:
             UpperCamelCase				:   str          =							ids_tensor([self.batch_size, self.seq_length]    ,      self.type_vocab_size )
  
         UpperCamelCase				:   List[str]          =							None
         UpperCamelCase				:   Optional[int]          =							None
         UpperCamelCase				:   Optional[int]          =							None
         if self.use_labels:
             UpperCamelCase				:   str          =							ids_tensor([self.batch_size]    ,      self.type_sequence_label_size )
             UpperCamelCase				:   Any          =							ids_tensor([self.batch_size, self.seq_length]    ,      self.num_labels )
             UpperCamelCase				:   List[Any]          =							ids_tensor([self.batch_size]    ,      self.num_choices )
  
         UpperCamelCase				:   Optional[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       a_							(							self    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_ ):
         UpperCamelCase				:   Optional[int]          =							TFAlbertModel(config=SCREAMING_SNAKE_CASE_ )
         # inputs = {'input_ids': input_ids,
         #           'attention_mask': input_mask,
         #           'token_type_ids': token_type_ids}
         # sequence_output, pooled_output = model(**inputs)
         UpperCamelCase				:   int          =							{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
         UpperCamelCase				:   Tuple          =							model(SCREAMING_SNAKE_CASE_ )
  
         UpperCamelCase				:   Union[str, Any]          =							[input_ids, input_mask]
         UpperCamelCase				:   str          =							model(SCREAMING_SNAKE_CASE_ )
  
         UpperCamelCase				:   Union[str, Any]          =							model(SCREAMING_SNAKE_CASE_ )
  
         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       a_							(							self    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_ ):
         UpperCamelCase				:   Dict          =							self.num_labels
         UpperCamelCase				:   Optional[Any]          =							TFAlbertForPreTraining(config=SCREAMING_SNAKE_CASE_ )
         UpperCamelCase				:   List[Any]          =							{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
         UpperCamelCase				:   List[str]          =							model(SCREAMING_SNAKE_CASE_ )
         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       a_							(							self    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_ ):
         UpperCamelCase				:   List[Any]          =							TFAlbertForMaskedLM(config=SCREAMING_SNAKE_CASE_ )
         UpperCamelCase				:   Union[str, Any]          =							{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
         UpperCamelCase				:   List[str]          =							model(SCREAMING_SNAKE_CASE_ )
         self.parent.assertEqual(result.logits.shape    ,      (self.batch_size, self.seq_length, self.vocab_size) )
  
  
  
  
  
  
  
     def       a_							(							self    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_ ):
         UpperCamelCase				:   Dict          =							self.num_labels
         UpperCamelCase				:   Optional[int]          =							TFAlbertForSequenceClassification(config=SCREAMING_SNAKE_CASE_ )
         UpperCamelCase				:   List[Any]          =							{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
         UpperCamelCase				:   Tuple          =							model(SCREAMING_SNAKE_CASE_ )
         self.parent.assertEqual(result.logits.shape    ,      (self.batch_size, self.num_labels) )
  
  
  
  
  
  
  
     def       a_							(							self    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_ ):
         UpperCamelCase				:   Any          =							TFAlbertForQuestionAnswering(config=SCREAMING_SNAKE_CASE_ )
         UpperCamelCase				:   Union[str, Any]          =							{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
         UpperCamelCase				:   int          =							model(SCREAMING_SNAKE_CASE_ )
         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       a_							(							self    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_ ):
         UpperCamelCase				:   Union[str, Any]          =							self.num_choices
         UpperCamelCase				:   Any          =							TFAlbertForMultipleChoice(config=SCREAMING_SNAKE_CASE_ )
         UpperCamelCase				:   Dict          =							tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE_    ,      1 )    ,      (1, self.num_choices, 1) )
         UpperCamelCase				:   Union[str, Any]          =							tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE_    ,      1 )    ,      (1, self.num_choices, 1) )
         UpperCamelCase				:   Dict          =							tf.tile(tf.expand_dims(SCREAMING_SNAKE_CASE_    ,      1 )    ,      (1, self.num_choices, 1) )
         UpperCamelCase				:   List[str]          =							{
             """input_ids""": multiple_choice_inputs_ids,
             """attention_mask""": multiple_choice_input_mask,
             """token_type_ids""": multiple_choice_token_type_ids,
         }
         UpperCamelCase				:   Optional[Any]          =							model(SCREAMING_SNAKE_CASE_ )
         self.parent.assertListEqual(list(result["""logits"""].shape )    ,      [self.batch_size, self.num_choices] )
  
  
  
  
  
  
  
     def       a_							(							self    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_ ):
         UpperCamelCase				:   Optional[int]          =							self.num_labels
         UpperCamelCase				:   Optional[int]          =							TFAlbertForTokenClassification(config=SCREAMING_SNAKE_CASE_ )
         UpperCamelCase				:   int          =							{
             """input_ids""": input_ids,
             """attention_mask""": input_mask,
             """token_type_ids""": token_type_ids,
         }
         UpperCamelCase				:   int          =							model(SCREAMING_SNAKE_CASE_ )
         self.parent.assertListEqual(list(result["""logits"""].shape )    ,      [self.batch_size, self.seq_length, self.num_labels] )
  
  
  
  
  
  
  
     def       a_							(							self ):
         UpperCamelCase				:   Dict          =							self.prepare_config_and_inputs()
         (
             (
             UpperCamelCase
         )       ,							(
             UpperCamelCase
         )       ,							(
             UpperCamelCase
         )       ,							(
             UpperCamelCase
         )       ,							(
             UpperCamelCase
         )       ,							(
             UpperCamelCase
         )       ,							(
             UpperCamelCase
         )       ,							
         )				:   Optional[Any]          =							config_and_inputs
         UpperCamelCase				:   int          =							{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
         return config, inputs_dict
  
  
  
  
  
  
  
  @require_tf
  class 							lowerCamelCase		( _UpperCAmelCase	,  _UpperCAmelCase	,  unittest.TestCase				):
     lowercase       :  Optional[int]      =				(
         (
             TFAlbertModel,
             TFAlbertForPreTraining,
             TFAlbertForMaskedLM,
             TFAlbertForSequenceClassification,
             TFAlbertForQuestionAnswering,
             TFAlbertForTokenClassification,
             TFAlbertForMultipleChoice,
         )
         if is_tf_available()
         else ()
     )
     lowercase       :  Tuple      =				(
         {
             'feature-extraction': TFAlbertModel,
             'fill-mask': TFAlbertForMaskedLM,
             'question-answering': TFAlbertForQuestionAnswering,
             'text-classification': TFAlbertForSequenceClassification,
             'token-classification': TFAlbertForTokenClassification,
             'zero-shot': TFAlbertForSequenceClassification,
         }
         if is_tf_available()
         else {}
     )
     lowercase       :  str      =				False
     lowercase       :  List[Any]      =				False
  
  
  
  
  
  
  
     def       a_							(							self    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_=False ):
         UpperCamelCase				:   str          =							super()._prepare_for_class(SCREAMING_SNAKE_CASE_    ,      SCREAMING_SNAKE_CASE_    ,      return_labels=SCREAMING_SNAKE_CASE_ )
  
         if return_labels:
             if model_class in get_values(SCREAMING_SNAKE_CASE_ ):
                 UpperCamelCase				:   Union[str, Any]          =							tf.zeros(self.model_tester.batch_size    ,      dtype=tf.intaa )
  
         return inputs_dict
  
  
  
  
  
  
  
     def       a_							(							self ):
         UpperCamelCase				:   Optional[Any]          =							TFAlbertModelTester(self )
         UpperCamelCase				:   List[Any]          =							ConfigTester(self    ,      config_class=SCREAMING_SNAKE_CASE_    ,      hidden_size=37 )
  
  
  
  
  
  
  
     def       a_							(							self ):
         self.config_tester.run_common_tests()
  
  
  
  
  
  
  
     def       a_							(							self ):
         UpperCamelCase				:   Optional[Any]          =							self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_albert_model(*SCREAMING_SNAKE_CASE_ )
  
  
  
  
  
  
  
     def       a_							(							self ):
         UpperCamelCase				:   List[Any]          =							self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_albert_for_pretraining(*SCREAMING_SNAKE_CASE_ )
  
  
  
  
  
  
  
     def       a_							(							self ):
         UpperCamelCase				:   Any          =							self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_albert_for_masked_lm(*SCREAMING_SNAKE_CASE_ )
  
  
  
  
  
  
  
     def       a_							(							self ):
         UpperCamelCase				:   List[str]          =							self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_albert_for_multiple_choice(*SCREAMING_SNAKE_CASE_ )
  
  
  
  
  
  
  
     def       a_							(							self ):
         UpperCamelCase				:   str          =							self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_albert_for_sequence_classification(*SCREAMING_SNAKE_CASE_ )
  
  
  
  
  
  
  
     def       a_							(							self ):
         UpperCamelCase				:   int          =							self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_albert_for_question_answering(*SCREAMING_SNAKE_CASE_ )
  
  
  
  
  
  
  
     @slow
     def       a_							(							self ):
         for model_name in TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             UpperCamelCase				:   Tuple          =							TFAlbertModel.from_pretrained(SCREAMING_SNAKE_CASE_ )
             self.assertIsNotNone(SCREAMING_SNAKE_CASE_ )
  
  
  
  
  
  
  
  @require_tf
  class 							lowerCamelCase		( unittest.TestCase				):
  
  
  
  
  
  
  
     @slow
     def       a_							(							self ):
         UpperCamelCase				:   Any          =							TFAlbertForPreTraining.from_pretrained("""albert-base-v2""" )
         UpperCamelCase				:   Optional[int]          =							tf.constant([[0, 1, 2, 3, 4, 5]] )
         UpperCamelCase				:   Union[str, Any]          =							model(SCREAMING_SNAKE_CASE_ )[0]
  
         UpperCamelCase				:   List[Any]          =							[1, 6, 3_0000]
         self.assertEqual(output.shape    ,      SCREAMING_SNAKE_CASE_ )
  
         UpperCamelCase				:   Optional[int]          =							tf.constant(
             [
                 [
                     [4.595668, 0.74462754, -1.818147],
                     [4.5954347, 0.7454184, -1.8188258],
                     [4.5954905, 0.7448235, -1.8182316],
                 ]
             ] )
         tf.debugging.assert_near(output[:, :3, :3]    ,      SCREAMING_SNAKE_CASE_    ,      atol=1e-4 )
  
  
  
  
  
style_context: 
  
  
  
  
  """simple docstring"""
  
  
  
  
  from ...utils import is_transformers_available
  from .pipeline_latent_diffusion_superresolution import LDMSuperResolutionPipeline
  
  
  if is_transformers_available():
    from .pipeline_latent_diffusion import LDMBertModel, LDMTextToImagePipeline
  
  
  
  
  