





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





        """simple docstring"""




        lowercase_    :Union[str, Any]					    =				parent
        lowercase_    :Optional[int]					    =				13
        lowercase_    :Tuple					    =				7
        lowercase_    :Union[str, Any]					    =				True
        lowercase_    :Any					    =				True
        lowercase_    :Dict					    =				True
        lowercase_    :Dict					    =				True
        lowercase_    :int					    =				99
        lowercase_    :Any					    =				16
        lowercase_    :Optional[Any]					    =				32
        lowercase_    :List[str]					    =				2
        lowercase_    :Optional[int]					    =				4
        lowercase_    :Optional[int]					    =				37
        lowercase_    :Union[str, Any]					    =				"gelu"
        lowercase_    :Optional[Any]					    =				0.1
        lowercase_    :List[str]					    =				0.1
        lowercase_    :int					    =				512
        lowercase_    :Dict					    =				16
        lowercase_    :Union[str, Any]					    =				2
        lowercase_    :List[Any]					    =				0.02
        lowercase_    :Tuple					    =				3
        lowercase_    :Optional[Any]					    =				4
        lowercase_    :Union[str, Any]					    =				None





     def 							lowercase__   (				self	:      Optional[int]		):





        """simple docstring"""




        lowercase_    :List[Any]					    =				ids_tensor([self.batch_size, self.seq_length]			,   self.vocab_size		)

        lowercase_    :Union[str, Any]					    =				None
        if self.use_input_mask:
           lowercase_    :Any					    =				random_attention_mask([self.batch_size, self.seq_length]		)

        lowercase_    :Optional[Any]					    =				None
        if self.use_token_type_ids:
           lowercase_    :int					    =				ids_tensor([self.batch_size, self.seq_length]			,   self.type_vocab_size		)

        lowercase_    :Dict					    =				None
        lowercase_    :int					    =				None
        lowercase_    :Optional[int]					    =				None
        if self.use_labels:
           lowercase_    :int					    =				ids_tensor([self.batch_size]			,   self.type_sequence_label_size		)
           lowercase_    :str					    =				ids_tensor([self.batch_size, self.seq_length]			,   self.num_labels		)
           lowercase_    :Tuple					    =				ids_tensor([self.batch_size]			,   self.num_choices		)

        lowercase_    :str					    =				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 							lowercase__   (				self	:      Any			,   lowercase	:      Optional[int]			,   lowercase	:      List[Any]			,   lowercase	:      Dict			,   lowercase	:      Any			,   lowercase	:      Any			,   lowercase	:      int			,   lowercase	:      Union[str, Any]		):





        """simple docstring"""




        lowercase_    :int					    =				TFAlbertModel(config=lowercase		)
        # inputs = {'input_ids': input_ids,
        #           'attention_mask': input_mask,
        #           'token_type_ids': token_type_ids}
        # sequence_output, pooled_output = model(**inputs)
        lowercase_    :Optional[Any]					    =				{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
        lowercase_    :Tuple					    =				model(lowercase		)

        lowercase_    :Optional[int]					    =				[input_ids, input_mask]
        lowercase_    :Optional[Any]					    =				model(lowercase		)

        lowercase_    :Union[str, Any]					    =				model(lowercase		)

        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 							lowercase__   (				self	:      Dict			,   lowercase	:      Optional[int]			,   lowercase	:      int			,   lowercase	:      Any			,   lowercase	:      Tuple			,   lowercase	:      Dict			,   lowercase	:      Tuple			,   lowercase	:      Optional[int]		):





        """simple docstring"""




        lowercase_    :List[str]					    =				self.num_labels
        lowercase_    :Union[str, Any]					    =				TFAlbertForPreTraining(config=lowercase		)
        lowercase_    :Dict					    =				{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
        lowercase_    :str					    =				model(lowercase		)
        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 							lowercase__   (				self	:      Optional[Any]			,   lowercase	:      Tuple			,   lowercase	:      List[Any]			,   lowercase	:      Any			,   lowercase	:      Tuple			,   lowercase	:      str			,   lowercase	:      Dict			,   lowercase	:      Dict		):





        """simple docstring"""




        lowercase_    :List[str]					    =				TFAlbertForMaskedLM(config=lowercase		)
        lowercase_    :Union[str, Any]					    =				{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
        lowercase_    :Dict					    =				model(lowercase		)
        self.parent.assertEqual(result.logits.shape			,   (self.batch_size, self.seq_length, self.vocab_size)		)





     def 							lowercase__   (				self	:      List[str]			,   lowercase	:      Union[str, Any]			,   lowercase	:      List[Any]			,   lowercase	:      Optional[Any]			,   lowercase	:      str			,   lowercase	:      Dict			,   lowercase	:      Dict			,   lowercase	:      int		):





        """simple docstring"""




        lowercase_    :List[str]					    =				self.num_labels
        lowercase_    :Optional[int]					    =				TFAlbertForSequenceClassification(config=lowercase		)
        lowercase_    :Union[str, Any]					    =				{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
        lowercase_    :Tuple					    =				model(lowercase		)
        self.parent.assertEqual(result.logits.shape			,   (self.batch_size, self.num_labels)		)





     def 							lowercase__   (				self	:      Tuple			,   lowercase	:      List[Any]			,   lowercase	:      Any			,   lowercase	:      int			,   lowercase	:      int			,   lowercase	:      str			,   lowercase	:      int			,   lowercase	:      str		):





        """simple docstring"""




        lowercase_    :List[Any]					    =				TFAlbertForQuestionAnswering(config=lowercase		)
        lowercase_    :Optional[Any]					    =				{"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}
        lowercase_    :Union[str, Any]					    =				model(lowercase		)
        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 							lowercase__   (				self	:      Optional[Any]			,   lowercase	:      List[Any]			,   lowercase	:      str			,   lowercase	:      Union[str, Any]			,   lowercase	:      int			,   lowercase	:      List[Any]			,   lowercase	:      Any			,   lowercase	:      Union[str, Any]		):





        """simple docstring"""




        lowercase_    :Dict					    =				self.num_choices
        lowercase_    :Any					    =				TFAlbertForMultipleChoice(config=lowercase		)
        lowercase_    :int					    =				tf.tile(tf.expand_dims(lowercase			,   1		)			,   (1, self.num_choices, 1)		)
        lowercase_    :Optional[Any]					    =				tf.tile(tf.expand_dims(lowercase			,   1		)			,   (1, self.num_choices, 1)		)
        lowercase_    :Dict					    =				tf.tile(tf.expand_dims(lowercase			,   1		)			,   (1, self.num_choices, 1)		)
        lowercase_    :Optional[Any]					    =				{
            "input_ids": multiple_choice_inputs_ids,
            "attention_mask": multiple_choice_input_mask,
            "token_type_ids": multiple_choice_token_type_ids,
        }
        lowercase_    :Optional[int]					    =				model(lowercase		)
        self.parent.assertListEqual(list(result["logits"].shape		)			,   [self.batch_size, self.num_choices]		)





     def 							lowercase__   (				self	:      str			,   lowercase	:      List[str]			,   lowercase	:      Any			,   lowercase	:      int			,   lowercase	:      Any			,   lowercase	:      List[Any]			,   lowercase	:      Optional[int]			,   lowercase	:      str		):





        """simple docstring"""




        lowercase_    :int					    =				self.num_labels
        lowercase_    :List[str]					    =				TFAlbertForTokenClassification(config=lowercase		)
        lowercase_    :Union[str, Any]					    =				{
            "input_ids": input_ids,
            "attention_mask": input_mask,
            "token_type_ids": token_type_ids,
        }
        lowercase_    :Tuple					    =				model(lowercase		)
        self.parent.assertListEqual(list(result["logits"].shape		)			,   [self.batch_size, self.seq_length, self.num_labels]		)







     def 							lowercase__   (				self	:      Tuple		):





        """simple docstring"""




        lowercase_    :Union[str, Any]					    =				self.prepare_config_and_inputs()
        (
            lowercase_							
        )    :Union[str, Any]					    =				config_and_inputs
        lowercase_    :Optional[int]					    =				{"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							):
     __A  				=    (
         (
             TFAlbertModel,
             TFAlbertForPreTraining,
             TFAlbertForMaskedLM,
             TFAlbertForSequenceClassification,
             TFAlbertForQuestionAnswering,
             TFAlbertForTokenClassification,
             TFAlbertForMultipleChoice,
         )
         if is_tf_available()
         else ()
     )
     __A  				=    (
         {
             "feature-extraction": TFAlbertModel,
             "fill-mask": TFAlbertForMaskedLM,
             "question-answering": TFAlbertForQuestionAnswering,
             "text-classification": TFAlbertForSequenceClassification,
             "token-classification": TFAlbertForTokenClassification,
             "zero-shot": TFAlbertForSequenceClassification,
         }
         if is_tf_available()
         else {}
     )
     __A  				=    False
     __A  				=    False





     def 							lowercase__   (				self	:      List[str]			,   lowercase	:      str			,   lowercase	:      Dict			,   lowercase	:      List[str]=False		):





        """simple docstring"""




        lowercase_    :int					    =				super()._prepare_for_class(lowercase			,   lowercase			,   return_labels=lowercase		)

        if return_labels:
           if model_class in get_values(lowercase		):
              lowercase_    :Optional[Any]					    =				tf.zeros(self.model_tester.batch_size			,   dtype=tf.intaa		)

        return inputs_dict





     def 							lowercase__   (				self	:      Union[str, Any]		):





        """simple docstring"""




        lowercase_    :Optional[int]					    =				TFAlbertModelTester(self		)
        lowercase_    :Tuple					    =				ConfigTester(self			,   config_class=lowercase			,   hidden_size=37		)





     def 							lowercase__   (				self	:      List[Any]		):





        """simple docstring"""




        self.config_tester.run_common_tests()





     def 							lowercase__   (				self	:      Dict		):





        """simple docstring"""




        lowercase_    :List[str]					    =				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_model(*lowercase		)





     def 							lowercase__   (				self	:      str		):





        """simple docstring"""




        lowercase_    :int					    =				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_pretraining(*lowercase		)





     def 							lowercase__   (				self	:      Tuple		):





        """simple docstring"""




        lowercase_    :Optional[int]					    =				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_masked_lm(*lowercase		)





     def 							lowercase__   (				self	:      int		):





        """simple docstring"""




        lowercase_    :Any					    =				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_multiple_choice(*lowercase		)





     def 							lowercase__   (				self	:      int		):





        """simple docstring"""




        lowercase_    :str					    =				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_sequence_classification(*lowercase		)





     def 							lowercase__   (				self	:      Any		):





        """simple docstring"""




        lowercase_    :Tuple					    =				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_albert_for_question_answering(*lowercase		)







     @slow
     def 							lowercase__   (				self	:      Optional[int]		):





        """simple docstring"""




        for model_name in TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
           lowercase_    :Union[str, Any]					    =				TFAlbertModel.from_pretrained(lowercase		)
           self.assertIsNotNone(lowercase		)







@require_tf
class    a_     (       unittest.TestCase							):





     @slow
     def 							lowercase__   (				self	:      List[Any]		):





        """simple docstring"""




        lowercase_    :Optional[int]					    =				TFAlbertForPreTraining.from_pretrained("albert-base-v2"		)
        lowercase_    :Dict					    =				tf.constant([[0, 1, 2, 3, 4, 5]]		)
        lowercase_    :Any					    =				model(lowercase		)[0]

        lowercase_    :List[Any]					    =				[1, 6, 30_000]
        self.assertEqual(output.shape			,   lowercase		)

        lowercase_    :List[str]					    =				tf.constant(
            [
                [
                    [4.59_56_68, 0.74_46_27_54, -1.81_81_47],
                    [4.5_95_43_47, 0.7_45_41_84, -1.8_18_82_58],
                    [4.5_95_49_05, 0.7_44_82_35, -1.8_18_23_16],
                ]
            ]		)
        tf.debugging.assert_near(output[:, :3, :3]			,   lowercase			,   atol=1e-4		)









'''simple docstring'''


import math
def 							UpperCAmelCase_						(		__lowerCamelCase      :      int				):

   if 1 < number < 4:
      # 2 and 3 are primes
      return True
   elif number < 2 or number % 2 == 0 or number % 3 == 0:
      # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
      return False

   # All primes number are in format of 6k +/- 1
   for i in range(5			,int(math.sqrt(__lowerCamelCase				) + 1				)			,6				):
      if number % i == 0 or number % (i + 2) == 0:
         return False
   return True
def 							UpperCAmelCase_						(		__lowerCamelCase      :      int = 2_00_00_00				):
   return sum(num for num in range(3			,__lowerCamelCase			,2				) if is_prime(__lowerCamelCase				)				) + 2 if n > 2 else 0


if __name__ == "__main__":
 print(F'''{solution() = }''')


