

'''simple docstring'''

from __future__ import annotations

import unittest

from transformers import DebertaConfig, 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 (
        TFDebertaForMaskedLM,
        TFDebertaForQuestionAnswering,
        TFDebertaForSequenceClassification,
        TFDebertaForTokenClassification,
        TFDebertaModel,
    )





class 							_snake_case	:
   def __init__(	self     : List[str]       ,SCREAMING_SNAKE_CASE__     : Union[str, Any]       ,SCREAMING_SNAKE_CASE__     : List[str]=13       ,SCREAMING_SNAKE_CASE__     : List[Any]=7       ,SCREAMING_SNAKE_CASE__     : int=True       ,SCREAMING_SNAKE_CASE__     : Optional[Any]=True       ,SCREAMING_SNAKE_CASE__     : List[Any]=True       ,SCREAMING_SNAKE_CASE__     : Optional[Any]=True       ,SCREAMING_SNAKE_CASE__     : Any=99       ,SCREAMING_SNAKE_CASE__     : Union[str, Any]=32       ,SCREAMING_SNAKE_CASE__     : Optional[int]=2       ,SCREAMING_SNAKE_CASE__     : Union[str, Any]=4       ,SCREAMING_SNAKE_CASE__     : Optional[int]=37       ,SCREAMING_SNAKE_CASE__     : List[str]="gelu"       ,SCREAMING_SNAKE_CASE__     : int=0.1       ,SCREAMING_SNAKE_CASE__     : Optional[int]=0.1       ,SCREAMING_SNAKE_CASE__     : List[str]=512       ,SCREAMING_SNAKE_CASE__     : Optional[int]=16       ,SCREAMING_SNAKE_CASE__     : Union[str, Any]=2       ,SCREAMING_SNAKE_CASE__     : Tuple=0.02       ,SCREAMING_SNAKE_CASE__     : Optional[Any]=3       ,SCREAMING_SNAKE_CASE__     : Optional[int]=4       ,SCREAMING_SNAKE_CASE__     : Any=None       ,):
     SCREAMING_SNAKE_CASE:Optional[int]   =   parent
     SCREAMING_SNAKE_CASE:Tuple   =   13
     SCREAMING_SNAKE_CASE:List[str]   =   7
     SCREAMING_SNAKE_CASE:Optional[int]   =   True
     SCREAMING_SNAKE_CASE:List[Any]   =   True
     SCREAMING_SNAKE_CASE:int   =   True
     SCREAMING_SNAKE_CASE:List[Any]   =   True
     SCREAMING_SNAKE_CASE:Tuple   =   99
     SCREAMING_SNAKE_CASE:List[str]   =   32
     SCREAMING_SNAKE_CASE:str   =   2
     SCREAMING_SNAKE_CASE:Union[str, Any]   =   4
     SCREAMING_SNAKE_CASE:Dict   =   37
     SCREAMING_SNAKE_CASE:Any   =   "gelu"
     SCREAMING_SNAKE_CASE:Dict   =   0.1
     SCREAMING_SNAKE_CASE:Optional[Any]   =   0.1
     SCREAMING_SNAKE_CASE:Union[str, Any]   =   512
     SCREAMING_SNAKE_CASE:Optional[Any]   =   16
     SCREAMING_SNAKE_CASE:List[Any]   =   False
     SCREAMING_SNAKE_CASE:Tuple   =   -1
     SCREAMING_SNAKE_CASE:str   =   True
     SCREAMING_SNAKE_CASE:Optional[Any]   =   2
     SCREAMING_SNAKE_CASE:List[str]   =   0.02
     SCREAMING_SNAKE_CASE:int   =   3
     SCREAMING_SNAKE_CASE:Any   =   4
     SCREAMING_SNAKE_CASE:Dict   =   None
   def       __UpperCamelCase  (	self     : Optional[int]							):
     SCREAMING_SNAKE_CASE:Dict   =   ids_tensor([self.batch_size, self.seq_length]       ,self.vocab_size							)

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

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

     SCREAMING_SNAKE_CASE:Optional[int]   =   None
     SCREAMING_SNAKE_CASE:int   =   None
     SCREAMING_SNAKE_CASE:Dict   =   None
     if self.use_labels:
       SCREAMING_SNAKE_CASE:Optional[Any]   =   ids_tensor([self.batch_size]       ,self.type_sequence_label_size							)
       SCREAMING_SNAKE_CASE:Any   =   ids_tensor([self.batch_size, self.seq_length]       ,self.num_labels							)

     SCREAMING_SNAKE_CASE:Optional[int]   =   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       ,relative_attention=self.relative_attention       ,max_relative_positions=self.max_relative_positions       ,position_biased_input=self.position_biased_input       ,initializer_range=self.initializer_range       ,return_dict=SCREAMING_SNAKE_CASE__       ,)

     return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
   def       __UpperCamelCase  (	self     : List[str]       ,SCREAMING_SNAKE_CASE__     : Dict       ,SCREAMING_SNAKE_CASE__     : Optional[Any]       ,SCREAMING_SNAKE_CASE__     : Optional[int]       ,SCREAMING_SNAKE_CASE__     : Optional[Any]       ,SCREAMING_SNAKE_CASE__     : Any       ,SCREAMING_SNAKE_CASE__     : int       ,SCREAMING_SNAKE_CASE__     : List[Any]							):
     SCREAMING_SNAKE_CASE:str   =   TFDebertaModel(config=SCREAMING_SNAKE_CASE__							)
     SCREAMING_SNAKE_CASE:Any   =   {"input_ids": input_ids, "attention_mask": input_mask, "token_type_ids": token_type_ids}

     SCREAMING_SNAKE_CASE:List[str]   =   [input_ids, input_mask]
     SCREAMING_SNAKE_CASE:Union[str, Any]   =   model(SCREAMING_SNAKE_CASE__							)

     SCREAMING_SNAKE_CASE:Tuple   =   model(SCREAMING_SNAKE_CASE__							)

     self.parent.assertEqual(result.last_hidden_state.shape       ,(self.batch_size, self.seq_length, self.hidden_size)							)
   def       __UpperCamelCase  (	self     : List[Any]       ,SCREAMING_SNAKE_CASE__     : List[str]       ,SCREAMING_SNAKE_CASE__     : int       ,SCREAMING_SNAKE_CASE__     : Any       ,SCREAMING_SNAKE_CASE__     : str       ,SCREAMING_SNAKE_CASE__     : Union[str, Any]       ,SCREAMING_SNAKE_CASE__     : int       ,SCREAMING_SNAKE_CASE__     : Tuple							):
     SCREAMING_SNAKE_CASE:int   =   TFDebertaForMaskedLM(config=SCREAMING_SNAKE_CASE__							)
     SCREAMING_SNAKE_CASE:Optional[Any]   =   {
         "input_ids": input_ids,
         "attention_mask": input_mask,
         "token_type_ids": token_type_ids,
     }
     SCREAMING_SNAKE_CASE:Optional[Any]   =   model(SCREAMING_SNAKE_CASE__							)
     self.parent.assertEqual(result.logits.shape       ,(self.batch_size, self.seq_length, self.vocab_size)							)
   def       __UpperCamelCase  (	self     : Tuple       ,SCREAMING_SNAKE_CASE__     : Dict       ,SCREAMING_SNAKE_CASE__     : str       ,SCREAMING_SNAKE_CASE__     : Dict       ,SCREAMING_SNAKE_CASE__     : List[str]       ,SCREAMING_SNAKE_CASE__     : Union[str, Any]       ,SCREAMING_SNAKE_CASE__     : Any       ,SCREAMING_SNAKE_CASE__     : Any							):
     SCREAMING_SNAKE_CASE:Optional[int]   =   self.num_labels
     SCREAMING_SNAKE_CASE:str   =   TFDebertaForSequenceClassification(config=SCREAMING_SNAKE_CASE__							)
     SCREAMING_SNAKE_CASE:Tuple   =   {
         "input_ids": input_ids,
         "attention_mask": input_mask,
         "token_type_ids": token_type_ids,
     }

     SCREAMING_SNAKE_CASE:Optional[Any]   =   model(SCREAMING_SNAKE_CASE__							)
     self.parent.assertEqual(result.logits.shape       ,(self.batch_size, self.num_labels)							)
   def       __UpperCamelCase  (	self     : Any       ,SCREAMING_SNAKE_CASE__     : Optional[Any]       ,SCREAMING_SNAKE_CASE__     : Optional[Any]       ,SCREAMING_SNAKE_CASE__     : Optional[Any]       ,SCREAMING_SNAKE_CASE__     : int       ,SCREAMING_SNAKE_CASE__     : int       ,SCREAMING_SNAKE_CASE__     : int       ,SCREAMING_SNAKE_CASE__     : Union[str, Any]							):
     SCREAMING_SNAKE_CASE:Any   =   self.num_labels
     SCREAMING_SNAKE_CASE:Dict   =   TFDebertaForTokenClassification(config=SCREAMING_SNAKE_CASE__							)
     SCREAMING_SNAKE_CASE:str   =   {
         "input_ids": input_ids,
         "attention_mask": input_mask,
         "token_type_ids": token_type_ids,
     }
     SCREAMING_SNAKE_CASE:Optional[int]   =   model(SCREAMING_SNAKE_CASE__							)
     self.parent.assertEqual(result.logits.shape       ,(self.batch_size, self.seq_length, self.num_labels)							)
   def       __UpperCamelCase  (	self     : str       ,SCREAMING_SNAKE_CASE__     : Any       ,SCREAMING_SNAKE_CASE__     : Union[str, Any]       ,SCREAMING_SNAKE_CASE__     : List[str]       ,SCREAMING_SNAKE_CASE__     : Optional[int]       ,SCREAMING_SNAKE_CASE__     : Optional[Any]       ,SCREAMING_SNAKE_CASE__     : Tuple       ,SCREAMING_SNAKE_CASE__     : Dict							):
     SCREAMING_SNAKE_CASE:List[str]   =   TFDebertaForQuestionAnswering(config=SCREAMING_SNAKE_CASE__							)
     SCREAMING_SNAKE_CASE:Optional[Any]   =   {
         "input_ids": input_ids,
         "attention_mask": input_mask,
         "token_type_ids": token_type_ids,
     }

     SCREAMING_SNAKE_CASE:str   =   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       __UpperCamelCase  (	self     : Union[str, Any]							):
     SCREAMING_SNAKE_CASE:int   =   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
     ) ,      
     ):List[Any]   =   config_and_inputs
     SCREAMING_SNAKE_CASE:List[Any]   =   {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
     return config, inputs_dict





@require_tf
class 							_snake_case	(    _a		,					_a		,					unittest.TestCase  ):
   _A    :       Any      				=   (
       (
           TFDebertaModel,
           TFDebertaForMaskedLM,
           TFDebertaForQuestionAnswering,
           TFDebertaForSequenceClassification,
           TFDebertaForTokenClassification,
       )
       if is_tf_available()
       else ()
   )
   _A    :       List[str]      				=   (
       {
           '''feature-extraction''': TFDebertaModel,
           '''fill-mask''': TFDebertaForMaskedLM,
           '''question-answering''': TFDebertaForQuestionAnswering,
           '''text-classification''': TFDebertaForSequenceClassification,
           '''token-classification''': TFDebertaForTokenClassification,
           '''zero-shot''': TFDebertaForSequenceClassification,
       }
       if is_tf_available()
       else {}
   )

   _A    :       Any      				=   False
   _A    :       List[Any]      				=   False
   def       __UpperCamelCase  (	self     : Tuple							):
     SCREAMING_SNAKE_CASE:Tuple   =   TFDebertaModelTester(self							)
     SCREAMING_SNAKE_CASE:Tuple   =   ConfigTester(self       ,config_class=SCREAMING_SNAKE_CASE__       ,hidden_size=37							)
   def       __UpperCamelCase  (	self     : Optional[Any]							):
     self.config_tester.run_common_tests()
   def       __UpperCamelCase  (	self     : List[str]							):
     SCREAMING_SNAKE_CASE:Tuple   =   self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : List[Any]							):
     SCREAMING_SNAKE_CASE:Optional[Any]   =   self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_masked_lm(*SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : str							):
     SCREAMING_SNAKE_CASE:List[Any]   =   self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_question_answering(*SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : Optional[Any]							):
     SCREAMING_SNAKE_CASE:str   =   self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_sequence_classification(*SCREAMING_SNAKE_CASE__							)
   def       __UpperCamelCase  (	self     : Dict							):
     SCREAMING_SNAKE_CASE:Optional[int]   =   self.model_tester.prepare_config_and_inputs()
     self.model_tester.create_and_check_for_token_classification(*SCREAMING_SNAKE_CASE__							)







   @slow
   def       __UpperCamelCase  (	self     : int							):
     SCREAMING_SNAKE_CASE:Optional[Any]   =   TFDebertaModel.from_pretrained("kamalkraj/deberta-base"							)
     self.assertIsNotNone(SCREAMING_SNAKE_CASE__							)





@require_tf
class 							_snake_case	(    unittest.TestCase  ):
   @unittest.skip(reason="Model not available yet"							)
   def       __UpperCamelCase  (	self     : Optional[int]							):
     pass







   @slow
   def       __UpperCamelCase  (	self     : List[Any]							):
     SCREAMING_SNAKE_CASE:Dict   =   TFDebertaModel.from_pretrained("kamalkraj/deberta-base"							)
     SCREAMING_SNAKE_CASE:int   =   tf.constant([[0, 31_414, 232, 328, 740, 1_140, 12_695, 69, 46_078, 1_588, 2]]							)
     SCREAMING_SNAKE_CASE:Dict   =   tf.constant([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]							)
     SCREAMING_SNAKE_CASE:Optional[int]   =   model(SCREAMING_SNAKE_CASE__       ,attention_mask=SCREAMING_SNAKE_CASE__							)[0]

     SCREAMING_SNAKE_CASE:Optional[int]   =   tf.constant(
         [
             [
                 [-0.59_855_896, -0.80_552_566, -0.8_462_135],
                 [1.4_484_025, -0.93_483_794, -0.80_593_085],
                 [0.3_122_741, 0.00_316_059, -1.4_131_377],
             ]
         ]							)
     tf.debugging.assert_near(output[:, 1:4, 1:4]       ,SCREAMING_SNAKE_CASE__       ,atol=1e-4							)









'''simple docstring'''

from __future__ import annotations

from collections import Counter





def 				A_					(	snake_case	):
  SCREAMING_SNAKE_CASE:int   =   [True] * n
  SCREAMING_SNAKE_CASE:List[str]   =   False
  SCREAMING_SNAKE_CASE:Tuple   =   False
  SCREAMING_SNAKE_CASE:int   =   True

  for i in range(3 ,    int(n**0.5 + 1	) ,    2	):
    SCREAMING_SNAKE_CASE:str   =   i * 2
    while index < n:
      SCREAMING_SNAKE_CASE:Any   =   False
      SCREAMING_SNAKE_CASE:List[Any]   =   index + i

  SCREAMING_SNAKE_CASE:Union[str, Any]   =   [2]

  for i in range(3 ,    snake_case ,    2	):
    if is_prime[i]:
      primes.append(snake_case	)

  return primes





def 				A_					(	snake_case	):
  SCREAMING_SNAKE_CASE:List[str]   =   str(snake_case	)
  SCREAMING_SNAKE_CASE:Union[str, Any]   =   []
  SCREAMING_SNAKE_CASE:List[str]   =   ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

  for duplicate in Counter(snake_case	) - Counter(set(snake_case	)	):
    SCREAMING_SNAKE_CASE:List[str]   =   [int(number_str.replace(snake_case ,    snake_case	)	) for digit in digits]
    replacements.append(snake_case	)

  return replacements





def 				A_					(	snake_case = 8	):
  SCREAMING_SNAKE_CASE:str   =   set()

  # Filter primes with less than 3 replaceable digits
  SCREAMING_SNAKE_CASE:Tuple   =   {
      x for x in set(prime_sieve(1000000	)	) if len(str(snake_case	)	) - len(set(str(snake_case	)	)	) >= 3
  }

  for prime in primes:
    if prime in numbers_checked:
      continue

    SCREAMING_SNAKE_CASE:List[Any]   =   digit_replacements(snake_case	)

    for family in replacements:
      numbers_checked.update(snake_case	)
      SCREAMING_SNAKE_CASE:Optional[Any]   =   primes.intersection(snake_case	)

      if len(snake_case	) != family_length:
        continue

      return min(snake_case	)

  return -1


if __name__ == "__main__":
    print(solution())






