

'''simple docstring'''



from __future__ import annotations

import unittest

from transformers import DebertaVaConfig, is_tf_available
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 (
		    TFDebertaVaForMaskedLM,
		    TFDebertaVaForQuestionAnswering,
		    TFDebertaVaForSequenceClassification,
		    TFDebertaVaForTokenClassification,
		    TFDebertaVaModel,
		)



class lowerCamelCase :



			'''simple docstring'''






			def __init__(      self       :						Dict		,			lowerCAmelCase_       :						int		,			lowerCAmelCase_       :						str=13		,			lowerCAmelCase_       :						List[str]=7		,			lowerCAmelCase_       :						Union[str, Any]=True		,			lowerCAmelCase_       :						Optional[Any]=True		,			lowerCAmelCase_       :						str=True		,			lowerCAmelCase_       :						Union[str, Any]=True		,			lowerCAmelCase_       :						Tuple=99		,			lowerCAmelCase_       :						Union[str, Any]=32		,			lowerCAmelCase_       :						Tuple=2		,			lowerCAmelCase_       :						Dict=4		,			lowerCAmelCase_       :						List[str]=37		,			lowerCAmelCase_       :						Tuple="gelu"		,			lowerCAmelCase_       :						Optional[int]=0.1		,			lowerCAmelCase_       :						str=0.1		,			lowerCAmelCase_       :						Any=5_12		,			lowerCAmelCase_       :						Union[str, Any]=16		,			lowerCAmelCase_       :						Union[str, Any]=2		,			lowerCAmelCase_       :						str=0.02		,			lowerCAmelCase_       :						int=False		,			lowerCAmelCase_       :						List[Any]=True		,			lowerCAmelCase_       :						List[str]="None"		,			lowerCAmelCase_       :						Union[str, Any]=3		,			lowerCAmelCase_       :						Tuple=4		,			lowerCAmelCase_       :						Tuple=None		,			)			->		Optional[Any]:





									'''simple docstring'''
									A__     :   Any      =parent
									A__     :   Any      =batch_size
									A__     :   Tuple      =seq_length
									A__     :   Tuple      =is_training
									A__     :   List[Any]      =use_input_mask
									A__     :   int      =use_token_type_ids
									A__     :   List[Any]      =use_labels
									A__     :   List[str]      =vocab_size
									A__     :   Optional[int]      =hidden_size
									A__     :   Optional[int]      =num_hidden_layers
									A__     :   str      =num_attention_heads
									A__     :   Tuple      =intermediate_size
									A__     :   Union[str, Any]      =hidden_act
									A__     :   Tuple      =hidden_dropout_prob
									A__     :   Optional[Any]      =attention_probs_dropout_prob
									A__     :   Tuple      =max_position_embeddings
									A__     :   str      =type_vocab_size
									A__     :   Dict      =type_sequence_label_size
									A__     :   List[Any]      =initializer_range
									A__     :   Any      =num_labels
									A__     :   Optional[Any]      =num_choices
									A__     :   Optional[int]      =relative_attention
									A__     :   Tuple      =position_biased_input
									A__     :   Union[str, Any]      =pos_att_type
									A__     :   Union[str, Any]      =scope


			def lowercase__						(      self       :						Dict )			->		str:





									'''simple docstring'''
									A__     :   Optional[int]      =ids_tensor([self.batch_size, self.seq_length]		,			self.vocab_size )

									A__     :   Tuple      =None
									if self.use_input_mask:
															A__     :   Dict      =random_attention_mask([self.batch_size, self.seq_length] )

									A__     :   Dict      =None
									if self.use_token_type_ids:
															A__     :   Union[str, Any]      =ids_tensor([self.batch_size, self.seq_length]		,			self.type_vocab_size )

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

									A__     :   List[Any]      =DebertaVaConfig(
									    vocab_size=self.vocab_size		,			hidden_size=self.hidden_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		,			relative_attention=self.relative_attention		,			position_biased_input=self.position_biased_input		,			initializer_range=self.initializer_range		,			return_dict=lowerCAmelCase_		,			)

									return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels


			def lowercase__						(      self       :						str		,			lowerCAmelCase_       :						Optional[int]		,			lowerCAmelCase_       :						Union[str, Any]		,			lowerCAmelCase_       :						Tuple		,			lowerCAmelCase_       :						Dict		,			lowerCAmelCase_       :						Dict		,			lowerCAmelCase_       :						Optional[int]		,			lowerCAmelCase_       :						List[Any] )			->		Optional[Any]:





									'''simple docstring'''
									A__     :   List[str]      =TFDebertaVaModel(config=lowerCAmelCase_ )
									A__     :   Any      ={"""input_ids""": input_ids, """attention_mask""": input_mask, """token_type_ids""": token_type_ids}

									A__     :   List[str]      =[input_ids, input_mask]
									A__     :   Optional[int]      =model(lowerCAmelCase_ )

									A__     :   Union[str, Any]      =model(lowerCAmelCase_ )

									self.parent.assertEqual(result.last_hidden_state.shape		,			(self.batch_size, self.seq_length, self.hidden_size) )


			def lowercase__						(      self       :						Optional[int]		,			lowerCAmelCase_       :						str		,			lowerCAmelCase_       :						Union[str, Any]		,			lowerCAmelCase_       :						Optional[int]		,			lowerCAmelCase_       :						str		,			lowerCAmelCase_       :						Optional[int]		,			lowerCAmelCase_       :						str		,			lowerCAmelCase_       :						Tuple )			->		Optional[int]:





									'''simple docstring'''
									A__     :   List[Any]      =TFDebertaVaForMaskedLM(config=lowerCAmelCase_ )
									A__     :   Optional[int]      ={
									    """input_ids""": input_ids,
									    """attention_mask""": input_mask,
									    """token_type_ids""": token_type_ids,
									}
									A__     :   List[str]      =model(lowerCAmelCase_ )
									self.parent.assertEqual(result.logits.shape		,			(self.batch_size, self.seq_length, self.vocab_size) )


			def lowercase__						(      self       :						Any		,			lowerCAmelCase_       :						Tuple		,			lowerCAmelCase_       :						Union[str, Any]		,			lowerCAmelCase_       :						List[str]		,			lowerCAmelCase_       :						Optional[int]		,			lowerCAmelCase_       :						Optional[Any]		,			lowerCAmelCase_       :						Optional[int]		,			lowerCAmelCase_       :						Dict )			->		List[str]:





									'''simple docstring'''
									A__     :   Any      =self.num_labels
									A__     :   List[str]      =TFDebertaVaForSequenceClassification(config=lowerCAmelCase_ )
									A__     :   Optional[int]      ={
									    """input_ids""": input_ids,
									    """attention_mask""": input_mask,
									    """token_type_ids""": token_type_ids,
									}

									A__     :   int      =model(lowerCAmelCase_ )
									self.parent.assertEqual(result.logits.shape		,			(self.batch_size, self.num_labels) )


			def lowercase__						(      self       :						Any		,			lowerCAmelCase_       :						str		,			lowerCAmelCase_       :						Optional[int]		,			lowerCAmelCase_       :						List[str]		,			lowerCAmelCase_       :						List[str]		,			lowerCAmelCase_       :						List[str]		,			lowerCAmelCase_       :						int		,			lowerCAmelCase_       :						Dict )			->		Any:





									'''simple docstring'''
									A__     :   int      =self.num_labels
									A__     :   Tuple      =TFDebertaVaForTokenClassification(config=lowerCAmelCase_ )
									A__     :   int      ={
									    """input_ids""": input_ids,
									    """attention_mask""": input_mask,
									    """token_type_ids""": token_type_ids,
									}
									A__     :   str      =model(lowerCAmelCase_ )
									self.parent.assertEqual(result.logits.shape		,			(self.batch_size, self.seq_length, self.num_labels) )


			def lowercase__						(      self       :						List[str]		,			lowerCAmelCase_       :						Any		,			lowerCAmelCase_       :						Optional[Any]		,			lowerCAmelCase_       :						Tuple		,			lowerCAmelCase_       :						List[str]		,			lowerCAmelCase_       :						Optional[int]		,			lowerCAmelCase_       :						int		,			lowerCAmelCase_       :						str )			->		List[str]:





									'''simple docstring'''
									A__     :   Optional[Any]      =TFDebertaVaForQuestionAnswering(config=lowerCAmelCase_ )
									A__     :   List[Any]      ={
									    """input_ids""": input_ids,
									    """attention_mask""": input_mask,
									    """token_type_ids""": token_type_ids,
									}

									A__     :   Union[str, Any]      =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 lowercase__						(      self       :						Tuple )			->		Tuple:





									'''simple docstring'''
									A__     :   Union[str, Any]      =self.prepare_config_and_inputs()
									(
									    (
									    A__							
									)    ,						(
									    A__							
									)    ,						(
									    A__							
									)    ,						(
									    A__							
									)    ,						(
									    A__							
									)    ,						(
									    A__							
									)    ,						(
									    A__							
									)    ,													
									)     :   str      =config_and_inputs
									A__     :   Optional[int]      ={"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
									return config, inputs_dict



@require_tf
class lowerCamelCase (  A_       ,						A_       ,						unittest.TestCase						):



			'''simple docstring'''






			__snake_case    	=       (
			    (
			        TFDebertaVaModel,
			        TFDebertaVaForMaskedLM,
			        TFDebertaVaForQuestionAnswering,
			        TFDebertaVaForSequenceClassification,
			        TFDebertaVaForTokenClassification,
			    )
			    if is_tf_available()
			    else ()
			)
			__snake_case    	=       (
			    {
			        '''feature-extraction''': TFDebertaVaModel,
			        '''fill-mask''': TFDebertaVaForMaskedLM,
			        '''question-answering''': TFDebertaVaForQuestionAnswering,
			        '''text-classification''': TFDebertaVaForSequenceClassification,
			        '''token-classification''': TFDebertaVaForTokenClassification,
			        '''zero-shot''': TFDebertaVaForSequenceClassification,
			    }
			    if is_tf_available()
			    else {}
			)

			__snake_case    	=       False
			__snake_case    	=       False


			def lowercase__						(      self       :						int )			->		Optional[Any]:





									'''simple docstring'''
									A__     :   Any      =TFDebertaVaModelTester(self )
									A__     :   str      =ConfigTester(self		,			config_class=lowerCAmelCase_		,			hidden_size=37 )


			def lowercase__						(      self       :						Dict )			->		Dict:





									'''simple docstring'''
									self.config_tester.run_common_tests()


			def lowercase__						(      self       :						Any )			->		List[str]:





									'''simple docstring'''
									A__     :   Union[str, Any]      =self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*lowerCAmelCase_ )


			def lowercase__						(      self       :						int )			->		str:





									'''simple docstring'''
									A__     :   List[str]      =self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_masked_lm(*lowerCAmelCase_ )


			def lowercase__						(      self       :						int )			->		List[str]:





									'''simple docstring'''
									A__     :   int      =self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_question_answering(*lowerCAmelCase_ )


			def lowercase__						(      self       :						str )			->		Optional[int]:





									'''simple docstring'''
									A__     :   Any      =self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_sequence_classification(*lowerCAmelCase_ )


			def lowercase__						(      self       :						int )			->		int:





									'''simple docstring'''
									A__     :   str      =self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_token_classification(*lowerCAmelCase_ )



			@slow
			def lowercase__						(      self       :						Tuple )			->		List[str]:





									'''simple docstring'''
									A__     :   str      =TFDebertaVaModel.from_pretrained("""kamalkraj/deberta-v2-xlarge""" )
									self.assertIsNotNone(lowerCAmelCase_ )



@require_tf
class lowerCamelCase (  unittest.TestCase						):



			'''simple docstring'''






			@unittest.skip(reason="""Model not available yet""" )
			def lowercase__						(      self       :						str )			->		Tuple:





									'''simple docstring'''
									pass



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





									'''simple docstring'''
									A__     :   Tuple      =TFDebertaVaModel.from_pretrained("""kamalkraj/deberta-v2-xlarge""" )
									A__     :   Union[str, Any]      =tf.constant([[0, 3_14_14, 2_32, 3_28, 7_40, 11_40, 1_26_95, 69, 4_60_78, 15_88, 2]] )
									A__     :   str      =tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] )
									A__     :   Optional[int]      =model(lowerCAmelCase_		,			attention_mask=lowerCAmelCase_ )[0]

									A__     :   Optional[Any]      =tf.constant(
									    [[[0.2356, 0.1948, 0.0369], [-0.1063, 0.3586, -0.5152], [-0.6399, -0.0259, -0.2525]]] )
									tf.debugging.assert_near(output[:, 1:4, 1:4]		,			lowerCAmelCase_		,			atol=1e-4 )





from math import isqrt







def        _lowerCamelCase(	lowercase__	)						->	bool:

		'''simple docstring'''







		return all(number % divisor != 0 for divisor in range(2   , isqrt(lowercase__	) + 1	)	)







def        _lowerCamelCase(	lowercase__ = 1_0**6	)						->	int:

		'''simple docstring'''







		__lowercase=			0
		__lowercase=			1
		__lowercase=			7
		while prime_candidate < max_prime:
				primes_count += is_prime(lowercase__	)

				cube_index += 1
				prime_candidate += 6 * cube_index

		return primes_count


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






