




'''simple docstring'''





import unittest

from transformers import DebertaConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch

		from transformers import (
		    DebertaForMaskedLM,
		    DebertaForQuestionAnswering,
		    DebertaForSequenceClassification,
		    DebertaForTokenClassification,
		    DebertaModel,
		)
		from transformers.models.deberta.modeling_deberta import DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST




class  _snake_case		(	lowercase_							):




			def __init__(					self				,							a__				,							a__=13				,							a__=7				,							a__=True				,							a__=True				,							a__=True				,							a__=True				,							a__=99				,							a__=32				,							a__=5				,							a__=4				,							a__=37				,							a__="gelu"				,							a__=0.1				,							a__=0.1				,							a__=512				,							a__=16				,							a__=2				,							a__=0.0_2				,							a__=False				,							a__=True				,							a__="None"				,							a__=3				,							a__=4				,							a__=None				,							)				->				List[Any]:

										'''simple docstring'''




										snake_case_						=      parent
										snake_case_						=      batch_size
										snake_case_						=      seq_length
										snake_case_						=      is_training
										snake_case_						=      use_input_mask
										snake_case_						=      use_token_type_ids
										snake_case_						=      use_labels
										snake_case_						=      vocab_size
										snake_case_						=      hidden_size
										snake_case_						=      num_hidden_layers
										snake_case_						=      num_attention_heads
										snake_case_						=      intermediate_size
										snake_case_						=      hidden_act
										snake_case_						=      hidden_dropout_prob
										snake_case_						=      attention_probs_dropout_prob
										snake_case_						=      max_position_embeddings
										snake_case_						=      type_vocab_size
										snake_case_						=      type_sequence_label_size
										snake_case_						=      initializer_range
										snake_case_						=      num_labels
										snake_case_						=      num_choices
										snake_case_						=      relative_attention
										snake_case_						=      position_biased_input
										snake_case_						=      pos_att_type
										snake_case_						=      scope




			def    lowerCAmelCase__				(					self							)				->				Tuple:

										'''simple docstring'''




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

										snake_case_						=      None
										if self.use_input_mask:
																	snake_case_						=      ids_tensor([self.batch_size, self.seq_length]				,							vocab_size=2							)

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

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

										snake_case_						=      self.get_config()

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




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

										'''simple docstring'''




										return DebertaConfig(
										    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				,							initializer_range=self.initializer_range				,							relative_attention=self.relative_attention				,							position_biased_input=self.position_biased_input				,							pos_att_type=self.pos_att_type				,							)




			def    lowerCAmelCase__				(					self							)				->				int:

										'''simple docstring'''




										snake_case_						=      self.get_config()
										snake_case_						=      300
										return config




			def    lowerCAmelCase__				(					self				,							a__							)				->				List[str]:

										'''simple docstring'''




										self.parent.assertListEqual(list(result.loss.size()							)				,							[]							)




			def    lowerCAmelCase__				(					self				,							a__				,							a__				,							a__				,							a__				,							a__				,							a__				,							a__							)				->				Any:

										'''simple docstring'''




										snake_case_						=      DebertaModel(config=a__							)
										model.to(a__							)
										model.eval()
										snake_case_						=      model(a__				,							attention_mask=a__				,							token_type_ids=a__							)[0]
										snake_case_						=      model(a__				,							token_type_ids=a__							)[0]
										snake_case_						=      model(a__							)[0]

										self.parent.assertListEqual(list(sequence_output.size()							)				,							[self.batch_size, self.seq_length, self.hidden_size]							)




			def    lowerCAmelCase__				(					self				,							a__				,							a__				,							a__				,							a__				,							a__				,							a__				,							a__							)				->				Any:

										'''simple docstring'''




										snake_case_						=      DebertaForMaskedLM(config=a__							)
										model.to(a__							)
										model.eval()
										snake_case_						=      model(a__				,							attention_mask=a__				,							token_type_ids=a__				,							labels=a__							)

										self.parent.assertEqual(result.logits.shape				,							(self.batch_size, self.seq_length, self.vocab_size)							)




			def    lowerCAmelCase__				(					self				,							a__				,							a__				,							a__				,							a__				,							a__				,							a__				,							a__							)				->				Union[str, Any]:

										'''simple docstring'''




										snake_case_						=      self.num_labels
										snake_case_						=      DebertaForSequenceClassification(a__							)
										model.to(a__							)
										model.eval()
										snake_case_						=      model(a__				,							attention_mask=a__				,							token_type_ids=a__				,							labels=a__							)
										self.parent.assertListEqual(list(result.logits.size()							)				,							[self.batch_size, self.num_labels]							)
										self.check_loss_output(a__							)




			def    lowerCAmelCase__				(					self				,							a__				,							a__				,							a__				,							a__				,							a__				,							a__				,							a__							)				->				Optional[int]:

										'''simple docstring'''




										snake_case_						=      self.num_labels
										snake_case_						=      DebertaForTokenClassification(config=a__							)
										model.to(a__							)
										model.eval()
										snake_case_						=      model(a__				,							attention_mask=a__				,							token_type_ids=a__				,							labels=a__							)
										self.parent.assertEqual(result.logits.shape				,							(self.batch_size, self.seq_length, self.num_labels)							)




			def    lowerCAmelCase__				(					self				,							a__				,							a__				,							a__				,							a__				,							a__				,							a__				,							a__							)				->				Optional[int]:

										'''simple docstring'''




										snake_case_						=      DebertaForQuestionAnswering(config=a__							)
										model.to(a__							)
										model.eval()
										snake_case_						=      model(
										    a__				,							attention_mask=a__				,							token_type_ids=a__				,							start_positions=a__				,							end_positions=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    lowerCAmelCase__				(					self							)				->				Dict:

										'''simple docstring'''




										snake_case_						=      self.prepare_config_and_inputs()
										(
										    (
										    snake_case_
										)					,      (
										    snake_case_
										)					,      (
										    snake_case_
										)					,      (
										    snake_case_
										)					,      (
										    snake_case_
										)					,      (
										    snake_case_
										)					,      (
										    snake_case_
										)					,      
										)						=      config_and_inputs
										snake_case_						=      {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
										return config, inputs_dict




@require_torch
class  _snake_case		(	lowercase_						,						lowercase_						,						unittest.TestCase							):
			lowerCAmelCase_     :      Optional[int]						       =    (
			    (
			        DebertaModel,
			        DebertaForMaskedLM,
			        DebertaForSequenceClassification,
			        DebertaForTokenClassification,
			        DebertaForQuestionAnswering,
			    )
			    if is_torch_available()
			    else ()
			)
			lowerCAmelCase_     :      Dict						       =    (
			    {
			        "feature-extraction": DebertaModel,
			        "fill-mask": DebertaForMaskedLM,
			        "question-answering": DebertaForQuestionAnswering,
			        "text-classification": DebertaForSequenceClassification,
			        "token-classification": DebertaForTokenClassification,
			        "zero-shot": DebertaForSequenceClassification,
			    }
			    if is_torch_available()
			    else {}
			)

			lowerCAmelCase_     :      Optional[int]						       =    True
			lowerCAmelCase_     :      Union[str, Any]						       =    False
			lowerCAmelCase_     :      Tuple						       =    False
			lowerCAmelCase_     :      Optional[int]						       =    False
			lowerCAmelCase_     :      Tuple						       =    False




			def    lowerCAmelCase__				(					self							)				->				int:

										'''simple docstring'''




										snake_case_						=      DebertaModelTester(self							)
										snake_case_						=      ConfigTester(self				,							config_class=a__				,							hidden_size=37							)




			def    lowerCAmelCase__				(					self							)				->				int:

										'''simple docstring'''




										self.config_tester.run_common_tests()




			def    lowerCAmelCase__				(					self							)				->				Dict:

										'''simple docstring'''




										snake_case_						=      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_deberta_model(*a__							)




			def    lowerCAmelCase__				(					self							)				->				Dict:

										'''simple docstring'''




										snake_case_						=      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_deberta_for_sequence_classification(*a__							)




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

										'''simple docstring'''




										snake_case_						=      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_deberta_for_masked_lm(*a__							)




			def    lowerCAmelCase__				(					self							)				->				str:

										'''simple docstring'''




										snake_case_						=      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_deberta_for_question_answering(*a__							)




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

										'''simple docstring'''




										snake_case_						=      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_deberta_for_token_classification(*a__							)




			@slow
			def    lowerCAmelCase__				(					self							)				->				Union[str, Any]:

										'''simple docstring'''




										for model_name in DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																	snake_case_						=      DebertaModel.from_pretrained(a__							)
																	self.assertIsNotNone(a__							)




@require_torch
@require_sentencepiece
@require_tokenizers
class  _snake_case		(	unittest.TestCase							):




			@unittest.skip(reason="Model not available yet"							)
			def    lowerCAmelCase__				(					self							)				->				List[Any]:

										'''simple docstring'''




										pass




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

										'''simple docstring'''




										snake_case_						=      DebertaModel.from_pretrained("microsoft/deberta-base"							)

										snake_case_						=      torch.tensor([[0, 31_414, 232, 328, 740, 1_140, 12_695, 69, 46_078, 1_588, 2]]							)
										snake_case_						=      torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]							)
										with torch.no_grad():
																	snake_case_						=      model(a__				,							attention_mask=a__							)[0]
										# compare the actual values for a slice.
										snake_case_						=      torch.tensor(
										    [[[-0.5_9_8_6, -0.8_0_5_5, -0.8_4_6_2], [1.4_4_8_4, -0.9_3_4_8, -0.8_0_5_9], [0.3_1_2_3, 0.0_0_3_2, -1.4_1_3_1]]]							)
										self.assertTrue(torch.allclose(output[:, 1:4, 1:4]				,							a__				,							atol=1e-4							)				,							F'{output[:, 1:4, 1:4]}'							)











from __future__ import annotations

from functools import lru_cache
from math import ceil

__lowerCamelCase       :     str   =     100

__lowerCamelCase       :     Any   =     set(range(3, NUM_PRIMES, 2))
primes.add(2)
__lowerCamelCase       :     int

for prime in range(3, ceil(NUM_PRIMES**0.5), 2):
    if prime not in primes:
        continue
    primes.difference_update(set(range(prime * prime, NUM_PRIMES, prime)))



@lru_cache(maxsize=100     )
def 		A_				(     _lowerCAmelCase     )						-> set[int]:
 if number_to_partition < 0:
  return set()
 elif number_to_partition == 0:
  return {1}

 UpperCamelCase	:					set[int]       	=   set()
 UpperCamelCase	:					int
 UpperCamelCase	:					int

 for prime in primes:
  if prime > number_to_partition:
   continue
  for sub in partition(number_to_partition - prime     ):
   ret.add(sub * prime     )

 return ret



def 		A_				(     _lowerCAmelCase = 5000     )						-> int | None:
 for number_to_partition in range(1							,   _lowerCAmelCase     ):
  if len(partition(_lowerCAmelCase     )     ) > number_unique_partitions:
   return number_to_partition
 return None


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