





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


							def __init__(							self			:Optional[Any]							, __A			:Dict							, __A			:int=13							, __A			:int=7							, __A			:Any=True							, __A			:List[str]=True							, __A			:Tuple=True							, __A			:Any=True							, __A			:Optional[int]=99							, __A			:List[Any]=16							, __A			:Any=32							, __A			:int=2							, __A			:Optional[int]=4							, __A			:str=37							, __A			:Optional[Any]="gelu"							, __A			:Union[str, Any]=0.1							, __A			:Dict=0.1							, __A			:int=512							, __A			:Any=16							, __A			:Dict=2							, __A			:Union[str, Any]=0.0_2							, __A			:List[Any]=3							, __A			:int=4							, __A			:Union[str, Any]=None							, )      ->      List[Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					parent
									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.0_2
									SCREAMING_SNAKE_CASE__								=					3
									SCREAMING_SNAKE_CASE__								=					4
									SCREAMING_SNAKE_CASE__								=					None


							def    _snake_case     (							self			:Tuple						)      ->      Dict:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					ids_tensor([self.batch_size, self.seq_length]							, self.vocab_size						)

									SCREAMING_SNAKE_CASE__								=					None
									if self.use_input_mask:
											SCREAMING_SNAKE_CASE__								=					random_attention_mask([self.batch_size, self.seq_length]						)

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

									SCREAMING_SNAKE_CASE__								=					None
									SCREAMING_SNAKE_CASE__								=					None
									SCREAMING_SNAKE_CASE__								=					None
									if self.use_labels:
											SCREAMING_SNAKE_CASE__								=					ids_tensor([self.batch_size]							, self.type_sequence_label_size						)
											SCREAMING_SNAKE_CASE__								=					ids_tensor([self.batch_size, self.seq_length]							, self.num_labels						)
											SCREAMING_SNAKE_CASE__								=					ids_tensor([self.batch_size]							, self.num_choices						)

									SCREAMING_SNAKE_CASE__								=					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			:List[str]							, __A			:List[Any]							, __A			:str							, __A			:Tuple							, __A			:Any							, __A			:int							, __A			:Tuple							, __A			:Optional[Any]						)      ->      Optional[int]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					TFAlbertModel(config=__A						)
									# inputs = {'input_ids': input_ids,
									#           'attention_mask': input_mask,
									#           'token_type_ids': token_type_ids}
									# sequence_output, pooled_output = model(**inputs)
									SCREAMING_SNAKE_CASE__								=					{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
									SCREAMING_SNAKE_CASE__								=					model(__A						)

									SCREAMING_SNAKE_CASE__								=					[input_ids, input_mask]
									SCREAMING_SNAKE_CASE__								=					model(__A						)

									SCREAMING_SNAKE_CASE__								=					model(__A						)

									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			:Tuple							, __A			:str							, __A			:int							, __A			:Tuple							, __A			:List[str]							, __A			:List[Any]							, __A			:List[str]							, __A			:str						)      ->      Tuple:



									"""simple docstring"""



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



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					TFAlbertForMaskedLM(config=__A						)
									SCREAMING_SNAKE_CASE__								=					{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
									SCREAMING_SNAKE_CASE__								=					model(__A						)
									self.parent.assertEqual(result.logits.shape							, (self.batch_size, self.seq_length, self.vocab_size)						)


							def    _snake_case     (							self			:Any							, __A			:Optional[Any]							, __A			:Optional[Any]							, __A			:Any							, __A			:Tuple							, __A			:Any							, __A			:Tuple							, __A			:Any						)      ->      Tuple:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					self.num_labels
									SCREAMING_SNAKE_CASE__								=					TFAlbertForSequenceClassification(config=__A						)
									SCREAMING_SNAKE_CASE__								=					{"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}
									SCREAMING_SNAKE_CASE__								=					model(__A						)
									self.parent.assertEqual(result.logits.shape							, (self.batch_size, self.num_labels)						)


							def    _snake_case     (							self			:List[Any]							, __A			:Optional[Any]							, __A			:Dict							, __A			:Optional[Any]							, __A			:Any							, __A			:Dict							, __A			:List[Any]							, __A			:Any						)      ->      Tuple:



									"""simple docstring"""



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



									"""simple docstring"""



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


							def    _snake_case     (							self			:Union[str, Any]							, __A			:Tuple							, __A			:List[Any]							, __A			:List[Any]							, __A			:int							, __A			:Optional[int]							, __A			:Any							, __A			:Optional[Any]						)      ->      Optional[int]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					self.num_labels
									SCREAMING_SNAKE_CASE__								=					TFAlbertForTokenClassification(config=__A						)
									SCREAMING_SNAKE_CASE__								=					{
									    """input_ids""": input_ids,
									    """attention_mask""": input_mask,
									    """token_type_ids""": token_type_ids,
									}
									SCREAMING_SNAKE_CASE__								=					model(__A						)
									self.parent.assertListEqual(list(result["""logits"""].shape						)							, [self.batch_size, self.seq_length, self.num_labels]						)


							def    _snake_case     (							self			:Optional[int]						)      ->      Dict:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					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__
									)		,  
									)								=					config_and_inputs
									SCREAMING_SNAKE_CASE__								=					{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
									return config, inputs_dict




@require_tf
class      UpperCamelCase_				(   UpperCamelCase__ ,     UpperCamelCase__ ,     unittest.TestCase			):
							lowerCamelCase_							=    (
							    (
							        TFAlbertModel,
							        TFAlbertForPreTraining,
							        TFAlbertForMaskedLM,
							        TFAlbertForSequenceClassification,
							        TFAlbertForQuestionAnswering,
							        TFAlbertForTokenClassification,
							        TFAlbertForMultipleChoice,
							    )
							    if is_tf_available()
							    else ()
							)
							lowerCamelCase_							=    (
							    {
							        "feature-extraction": TFAlbertModel,
							        "fill-mask": TFAlbertForMaskedLM,
							        "question-answering": TFAlbertForQuestionAnswering,
							        "text-classification": TFAlbertForSequenceClassification,
							        "token-classification": TFAlbertForTokenClassification,
							        "zero-shot": TFAlbertForSequenceClassification,
							    }
							    if is_tf_available()
							    else {}
							)
							lowerCamelCase_							=    False
							lowerCamelCase_							=    False


							def    _snake_case     (							self			:List[str]							, __A			:Any							, __A			:Any							, __A			:List[str]=False						)      ->      str:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					super()._prepare_for_class(__A							, __A							, return_labels=__A						)

									if return_labels:
											if model_class in get_values(__A						):
													SCREAMING_SNAKE_CASE__								=					tf.zeros(self.model_tester.batch_size							, dtype=tf.intaa						)

									return inputs_dict


							def    _snake_case     (							self			:Union[str, Any]						)      ->      Dict:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					TFAlbertModelTester(self						)
									SCREAMING_SNAKE_CASE__								=					ConfigTester(self							, config_class=__A							, hidden_size=37						)


							def    _snake_case     (							self			:Any						)      ->      int:



									"""simple docstring"""



									self.config_tester.run_common_tests()


							def    _snake_case     (							self			:str						)      ->      List[str]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_albert_model(*__A						)


							def    _snake_case     (							self			:Union[str, Any]						)      ->      Tuple:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_albert_for_pretraining(*__A						)


							def    _snake_case     (							self			:str						)      ->      List[str]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_albert_for_masked_lm(*__A						)


							def    _snake_case     (							self			:Any						)      ->      Optional[Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_albert_for_multiple_choice(*__A						)


							def    _snake_case     (							self			:List[Any]						)      ->      List[Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_albert_for_sequence_classification(*__A						)


							def    _snake_case     (							self			:Optional[int]						)      ->      int:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_albert_for_question_answering(*__A						)


							@slow
							def    _snake_case     (							self			:int						)      ->      Optional[int]:



									"""simple docstring"""



									for model_name in TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											SCREAMING_SNAKE_CASE__								=					TFAlbertModel.from_pretrained(__A						)
											self.assertIsNotNone(__A						)




@require_tf
class      UpperCamelCase_				(   unittest.TestCase			):


							@slow
							def    _snake_case     (							self			:Dict						)      ->      List[str]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					TFAlbertForPreTraining.from_pretrained("""albert-base-v2"""						)
									SCREAMING_SNAKE_CASE__								=					tf.constant([[0, 1, 2, 3, 4, 5]]						)
									SCREAMING_SNAKE_CASE__								=					model(__A						)[0]

									SCREAMING_SNAKE_CASE__								=					[1, 6, 3_0000]
									self.assertEqual(output.shape							, __A						)

									SCREAMING_SNAKE_CASE__								=					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]							, __A							, atol=1E-4						)

'''simple docstring'''

from __future__ import annotations







def __A  (    lowerCAmelCase_       ):
     _UpperCAmelCase					:  Optional[int]         =    {1}
     _UpperCAmelCase					:  Union[str, Any]         =    [1]
     for _ in range(2 ,       depth + 1       ):
          _UpperCAmelCase					:  Dict         =    [*previous_coefficients, 0]
          _UpperCAmelCase					:  int         =    [0, *previous_coefficients]
          _UpperCAmelCase					:  List[Any]         =    []
          for x, y in zip(lowerCAmelCase_ ,       lowerCAmelCase_       ):
               coefficients.add(x + y       )
               previous_coefficients.append(x + y       )
     return coefficients







def __A  (    lowerCAmelCase_       ):
     _UpperCAmelCase					:  Dict         =    set()
     for number in unique_coefficients:
          _UpperCAmelCase					:  Tuple         =    2
          _UpperCAmelCase					:  List[str]         =    number
          while divisor**2 <= copy_number:
               _UpperCAmelCase					:  Tuple         =    0
               while copy_number % divisor == 0:
                    copy_number //= divisor
                    multiplicity += 1
               if multiplicity >= 2:
                    non_squarefrees.add(lowerCAmelCase_       )
                    break
               divisor += 1

     return unique_coefficients.difference(lowerCAmelCase_       )







def __A  (    lowerCAmelCase_ = 51       ):
     _UpperCAmelCase					:  List[str]         =    get_pascal_triangle_unique_coefficients(lowerCAmelCase_       )
     _UpperCAmelCase					:  Optional[Any]         =    get_squarefrees(lowerCAmelCase_       )
     return sum(lowerCAmelCase_       )


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


