




from math import sqrt



def      UpperCAmelCase_   (     __UpperCamelCase     ):
    SCREAMING_SNAKE_CASE__       =[1]
    for i in range(2,    int(sqrt(__UpperCamelCase     )     ) + 1,    1     ):
        if number % i == 0:
            values.append(__UpperCamelCase     )
            if int(number // i     ) != i:
                values.append(int(number // i     )     )
    return sorted(__UpperCamelCase     )



def      UpperCAmelCase_   (     __UpperCamelCase     ):
    return sum(factors(__UpperCamelCase     )     ) > n



def      UpperCAmelCase_   (     __UpperCamelCase     ):
    SCREAMING_SNAKE_CASE__       =factors(__UpperCamelCase     )
    SCREAMING_SNAKE_CASE__       =len(__UpperCamelCase     )
    SCREAMING_SNAKE_CASE__       =[[0 for i in range(number + 1     )] for j in range(r + 1     )]
    for i in range(r + 1     ):
        SCREAMING_SNAKE_CASE__       =True

    for i in range(1,    number + 1     ):
        SCREAMING_SNAKE_CASE__       =False

    for i in range(1,    r + 1     ):
        for j in range(1,    number + 1     ):
            if j < values[i - 1]:
                SCREAMING_SNAKE_CASE__       =subset[i - 1][j]
            else:
                SCREAMING_SNAKE_CASE__       =subset[i - 1][j] or subset[i - 1][j - values[i - 1]]

    return subset[r][number] != 0



def      UpperCAmelCase_   (     __UpperCamelCase     ):
    return abundant(__UpperCamelCase     ) and not semi_perfect(__UpperCamelCase     )


if __name__ == "__main__":
    import doctest

    doctest.testmod(verbose=True)
    for number in (69, 70, 71):
        print(f"""{number} is {'' if weird(number) else 'not '}weird.""")












import tempfile
import unittest

from transformers import DPRConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

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


if is_torch_available():
    import torch

    from transformers import DPRContextEncoder, DPRQuestionEncoder, DPRReader, DPRReaderTokenizer
    from transformers.models.dpr.modeling_dpr import (
        DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
        DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
        DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST,
    )
class 				__a :


     """simple docstring"""


     def __init__(     self      :			str    ,_UpperCamelCase      :			Dict    ,_UpperCamelCase      :			str=1_3    ,_UpperCamelCase      :			Any=7    ,_UpperCamelCase      :			str=False    ,_UpperCamelCase      :			Tuple=True    ,_UpperCamelCase      :			Optional[int]=True    ,_UpperCamelCase      :			Any=True    ,_UpperCamelCase      :			List[Any]=9_9    ,_UpperCamelCase      :			List[str]=3_2    ,_UpperCamelCase      :			Optional[int]=5    ,_UpperCamelCase      :			Union[str, Any]=4    ,_UpperCamelCase      :			Any=3_7    ,_UpperCamelCase      :			Dict="gelu"    ,_UpperCamelCase      :			List[str]=0.1    ,_UpperCamelCase      :			Dict=0.1    ,_UpperCamelCase      :			int=5_1_2    ,_UpperCamelCase      :			Optional[int]=1_6    ,_UpperCamelCase      :			Tuple=2    ,_UpperCamelCase      :			Tuple=0.02    ,_UpperCamelCase      :			int=3    ,_UpperCamelCase      :			Optional[Any]=4    ,_UpperCamelCase      :			Tuple=None    ,_UpperCamelCase      :			List[Any]=0    ,)		->       str:


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__       =parent
         SCREAMING_SNAKE_CASE__       =batch_size
         SCREAMING_SNAKE_CASE__       =seq_length
         SCREAMING_SNAKE_CASE__       =is_training
         SCREAMING_SNAKE_CASE__       =use_input_mask
         SCREAMING_SNAKE_CASE__       =use_token_type_ids
         SCREAMING_SNAKE_CASE__       =use_labels
         SCREAMING_SNAKE_CASE__       =vocab_size
         SCREAMING_SNAKE_CASE__       =hidden_size
         SCREAMING_SNAKE_CASE__       =num_hidden_layers
         SCREAMING_SNAKE_CASE__       =num_attention_heads
         SCREAMING_SNAKE_CASE__       =intermediate_size
         SCREAMING_SNAKE_CASE__       =hidden_act
         SCREAMING_SNAKE_CASE__       =hidden_dropout_prob
         SCREAMING_SNAKE_CASE__       =attention_probs_dropout_prob
         SCREAMING_SNAKE_CASE__       =max_position_embeddings
         SCREAMING_SNAKE_CASE__       =type_vocab_size
         SCREAMING_SNAKE_CASE__       =type_sequence_label_size
         SCREAMING_SNAKE_CASE__       =initializer_range
         SCREAMING_SNAKE_CASE__       =num_labels
         SCREAMING_SNAKE_CASE__       =num_choices
         SCREAMING_SNAKE_CASE__       =scope
         SCREAMING_SNAKE_CASE__       =projection_dim




     def   __A    (     self      :			str						)		->       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__       =self.get_config()

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




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


         '''simple docstring'''





         return DPRConfig(
             projection_dim=self.projection_dim    ,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    ,)




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


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__       =DPRContextEncoder(config=_UpperCamelCase						)
         model.to(_UpperCamelCase						)
         model.eval()
         SCREAMING_SNAKE_CASE__       =model(_UpperCamelCase    ,attention_mask=_UpperCamelCase    ,token_type_ids=_UpperCamelCase						)
         SCREAMING_SNAKE_CASE__       =model(_UpperCamelCase    ,token_type_ids=_UpperCamelCase						)
         SCREAMING_SNAKE_CASE__       =model(_UpperCamelCase						)
         self.parent.assertEqual(result.pooler_output.shape    ,(self.batch_size, self.projection_dim or self.hidden_size)						)




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


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__       =DPRQuestionEncoder(config=_UpperCamelCase						)
         model.to(_UpperCamelCase						)
         model.eval()
         SCREAMING_SNAKE_CASE__       =model(_UpperCamelCase    ,attention_mask=_UpperCamelCase    ,token_type_ids=_UpperCamelCase						)
         SCREAMING_SNAKE_CASE__       =model(_UpperCamelCase    ,token_type_ids=_UpperCamelCase						)
         SCREAMING_SNAKE_CASE__       =model(_UpperCamelCase						)
         self.parent.assertEqual(result.pooler_output.shape    ,(self.batch_size, self.projection_dim or self.hidden_size)						)




     def   __A    (     self      :			Dict    ,_UpperCamelCase      :			Any    ,_UpperCamelCase      :			Union[str, Any]    ,_UpperCamelCase      :			List[str]    ,_UpperCamelCase      :			Union[str, Any]    ,_UpperCamelCase      :			str    ,_UpperCamelCase      :			str    ,_UpperCamelCase      :			List[str]						)		->       Tuple:


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__       =DPRReader(config=_UpperCamelCase						)
         model.to(_UpperCamelCase						)
         model.eval()
         SCREAMING_SNAKE_CASE__       =model(
             _UpperCamelCase    ,attention_mask=_UpperCamelCase    ,)

         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)						)
         self.parent.assertEqual(result.relevance_logits.shape    ,(self.batch_size,)						)




     def   __A    (     self      :			List[Any]						)		->       int:


         '''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}
         return config, inputs_dict






@require_torch
class 				__a (			__lowerCamelCase							,					__lowerCamelCase							,					unittest.TestCase					):


     """simple docstring"""


     _A    :   Optional[int]     =  (
         (
             DPRContextEncoder,
             DPRQuestionEncoder,
             DPRReader,
         )
         if is_torch_available()
         else ()
     )
     _A    :   str     =  {"feature-extraction": DPRQuestionEncoder} if is_torch_available() else {}

     _A    :   List[Any]     =  False
     _A    :   Tuple     =  False  # why?
     _A    :   Optional[Any]     =  False
     _A    :   Dict     =  False




     def   __A    (     self      :			Tuple						)		->       List[Any]:


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__       =DPRModelTester(self						)
         SCREAMING_SNAKE_CASE__       =ConfigTester(self    ,config_class=_UpperCamelCase    ,hidden_size=3_7						)




     def   __A    (     self      :			Tuple						)		->       str:


         '''simple docstring'''





         self.config_tester.run_common_tests()




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


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__       =self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_context_encoder(*_UpperCamelCase						)




     def   __A    (     self      :			Optional[int]						)		->       Tuple:


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__       =self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_question_encoder(*_UpperCamelCase						)




     def   __A    (     self      :			int						)		->       Dict:


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__       =self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_reader(*_UpperCamelCase						)




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


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__       =self.model_tester.prepare_config_and_inputs()[0]

         SCREAMING_SNAKE_CASE__       =DPRQuestionEncoder(config=_UpperCamelCase						)
         model.to(_UpperCamelCase						)
         model.eval()

         with tempfile.TemporaryDirectory() as tmp_dirname:
             model.save_pretrained(_UpperCamelCase						)
             SCREAMING_SNAKE_CASE__       =DPRQuestionEncoder.from_pretrained(_UpperCamelCase    ,projection_dim=5_1_2						)

         self.assertIsNotNone(_UpperCamelCase						)




     @slow
     def   __A    (     self      :			List[Any]						)		->       int:


         '''simple docstring'''





         for model_name in DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             SCREAMING_SNAKE_CASE__       =DPRContextEncoder.from_pretrained(_UpperCamelCase						)
             self.assertIsNotNone(_UpperCamelCase						)

         for model_name in DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             SCREAMING_SNAKE_CASE__       =DPRContextEncoder.from_pretrained(_UpperCamelCase						)
             self.assertIsNotNone(_UpperCamelCase						)

         for model_name in DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             SCREAMING_SNAKE_CASE__       =DPRQuestionEncoder.from_pretrained(_UpperCamelCase						)
             self.assertIsNotNone(_UpperCamelCase						)

         for model_name in DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             SCREAMING_SNAKE_CASE__       =DPRReader.from_pretrained(_UpperCamelCase						)
             self.assertIsNotNone(_UpperCamelCase						)






@require_torch
class 				__a (			unittest.TestCase					):


     """simple docstring"""


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


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__       =DPRQuestionEncoder.from_pretrained("""facebook/dpr-question_encoder-single-nq-base"""    ,return_dict=_UpperCamelCase						)
         model.to(_UpperCamelCase						)

         SCREAMING_SNAKE_CASE__       =torch.tensor(
             [[1_0_1, 7_5_9_2, 1_0_1_0, 2_0_0_3, 2_0_2_6, 3_8_9_9, 1_0_1_4_0, 1_0_2_9, 1_0_2]]    ,dtype=torch.long    ,device=_UpperCamelCase						)  # [CLS] hello, is my dog cute? [SEP]
         SCREAMING_SNAKE_CASE__       =model(_UpperCamelCase						)[0]  # embedding shape = (1, 768)
         # compare the actual values for a slice.
         SCREAMING_SNAKE_CASE__       =torch.tensor(
             [
                 [
                     0.0323_6253,
                     0.1275_3335,
                     0.1681_8509,
                     0.0027_9786,
                     0.389_6933,
                     0.2426_4945,
                     0.217_8971,
                     -0.0233_5227,
                     -0.0848_1959,
                     -0.1432_4117,
                 ]
             ]    ,dtype=torch.float    ,device=_UpperCamelCase    ,)
         self.assertTrue(torch.allclose(output[:, :1_0]    ,_UpperCamelCase    ,atol=1e-4						)						)




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


         '''simple docstring'''





         SCREAMING_SNAKE_CASE__       =DPRReaderTokenizer.from_pretrained("""facebook/dpr-reader-single-nq-base"""						)
         SCREAMING_SNAKE_CASE__       =DPRReader.from_pretrained("""facebook/dpr-reader-single-nq-base"""						)
         model.to(_UpperCamelCase						)

         SCREAMING_SNAKE_CASE__       =tokenizer(
             questions="""What is love ?"""    ,titles="""Haddaway"""    ,texts="""What Is Love is a song recorded by the artist Haddaway"""    ,padding=_UpperCamelCase    ,return_tensors="""pt"""    ,)
         encoded_inputs.to(_UpperCamelCase						)

         SCREAMING_SNAKE_CASE__       =model(**_UpperCamelCase						)

         # compare the actual values for a slice.
         SCREAMING_SNAKE_CASE__       =torch.tensor(
             [[-10.3005, -10.7765, -11.4872, -11.6841, -11.9312, -10.3002, -9.8544, -11.7378, -12.0821, -10.2975]]    ,dtype=torch.float    ,device=_UpperCamelCase    ,)

         SCREAMING_SNAKE_CASE__       =torch.tensor(
             [[-11.0684, -11.7041, -11.5397, -10.3465, -10.8791, -6.8443, -11.9959, -11.0364, -10.0096, -6.8405]]    ,dtype=torch.float    ,device=_UpperCamelCase    ,)
         self.assertTrue(torch.allclose(outputs.start_logits[:, :1_0]    ,_UpperCamelCase    ,atol=1e-4						)						)
         self.assertTrue(torch.allclose(outputs.end_logits[:, :1_0]    ,_UpperCamelCase    ,atol=1e-4						)						)






