



"""simple docstring"""




import unittest

from transformers import AlbertConfig, is_torch_available
from transformers.models.auto import get_values
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 (
     MODEL_FOR_PRETRAINING_MAPPING,
     AlbertForMaskedLM,
     AlbertForMultipleChoice,
     AlbertForPreTraining,
     AlbertForQuestionAnswering,
     AlbertForSequenceClassification,
     AlbertForTokenClassification,
     AlbertModel,
 )
 from transformers.models.albert.modeling_albert import ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST






class      UpperCAmelCase_  :



      def __init__(					self					:     Tuple					,     A					:     str					,     A					:     Optional[Any]=1_3					,     A					:     Union[str, Any]=7					,     A					:     int=True					,     A					:     int=True					,     A					:     List[Any]=True					,     A					:     Optional[Any]=True					,     A					:     Optional[Any]=9_9					,     A					:     Optional[int]=1_6					,     A					:     Optional[Any]=3_6					,     A					:     Optional[Any]=6					,     A					:     List[Any]=6					,     A					:     Optional[int]=6					,     A					:     Dict=3_7					,     A					:     Optional[Any]="gelu"					,     A					:     Tuple=0.1					,     A					:     Any=0.1					,     A					:     str=5_1_2					,     A					:     int=1_6					,     A					:     List[Any]=2					,     A					:     Dict=0.02					,     A					:     Union[str, Any]=3					,     A					:     str=4					,     A					:     List[Any]=None					,     ):
           _UpperCAmelCase      :     Tuple        =   parent
           _UpperCAmelCase      :     Optional[int]        =   batch_size
           _UpperCAmelCase      :     Union[str, Any]        =   seq_length
           _UpperCAmelCase      :     str        =   is_training
           _UpperCAmelCase      :     Union[str, Any]        =   use_input_mask
           _UpperCAmelCase      :     Optional[int]        =   use_token_type_ids
           _UpperCAmelCase      :     Any        =   use_labels
           _UpperCAmelCase      :     Optional[int]        =   vocab_size
           _UpperCAmelCase      :     List[Any]        =   embedding_size
           _UpperCAmelCase      :     Dict        =   hidden_size
           _UpperCAmelCase      :     Union[str, Any]        =   num_hidden_layers
           _UpperCAmelCase      :     Union[str, Any]        =   num_hidden_groups
           _UpperCAmelCase      :     Dict        =   num_attention_heads
           _UpperCAmelCase      :     str        =   intermediate_size
           _UpperCAmelCase      :     Tuple        =   hidden_act
           _UpperCAmelCase      :     List[Any]        =   hidden_dropout_prob
           _UpperCAmelCase      :     int        =   attention_probs_dropout_prob
           _UpperCAmelCase      :     List[Any]        =   max_position_embeddings
           _UpperCAmelCase      :     List[str]        =   type_vocab_size
           _UpperCAmelCase      :     Optional[Any]        =   type_sequence_label_size
           _UpperCAmelCase      :     str        =   initializer_range
           _UpperCAmelCase      :     List[str]        =   num_labels
           _UpperCAmelCase      :     str        =   num_choices
           _UpperCAmelCase      :     Any        =   scope



      def 						snake_case_ (					self					:     int						):
           _UpperCAmelCase      :     int        =   ids_tensor([self.batch_size, self.seq_length]					,     self.vocab_size						)

           _UpperCAmelCase      :     List[Any]        =   None
           if self.use_input_mask:
                _UpperCAmelCase      :     Optional[Any]        =   random_attention_mask([self.batch_size, self.seq_length]						)

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

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

           _UpperCAmelCase      :     int        =   self.get_config()

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



      def 						snake_case_ (					self					:     Tuple						):
           return AlbertConfig(
               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					,     num_hidden_groups=self.num_hidden_groups					,     )



      def 						snake_case_ (					self					:     Dict					,     A					:     int					,     A					:     Optional[int]					,     A					:     Dict					,     A					:     int					,     A					:     Tuple					,     A					:     Dict					,     A					:     List[Any]						):
           _UpperCAmelCase      :     Optional[int]        =   AlbertModel(config=A						)
           model.to(A						)
           model.eval()
           _UpperCAmelCase      :     int        =   model(A					,     attention_mask=A					,     token_type_ids=A						)
           _UpperCAmelCase      :     List[Any]        =   model(A					,     token_type_ids=A						)
           _UpperCAmelCase      :     Any        =   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					:     List[str]					,     A					:     Optional[int]					,     A					:     Union[str, Any]					,     A					:     Optional[Any]					,     A					:     int					,     A					:     str					,     A					:     List[str]					,     A					:     Optional[int]						):
           _UpperCAmelCase      :     Dict        =   AlbertForPreTraining(config=A						)
           model.to(A						)
           model.eval()
           _UpperCAmelCase      :     Optional[int]        =   model(
               A					,     attention_mask=A					,     token_type_ids=A					,     labels=A					,     sentence_order_label=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, config.num_labels)						)



      def 						snake_case_ (					self					:     Optional[int]					,     A					:     List[Any]					,     A					:     Dict					,     A					:     Any					,     A					:     Any					,     A					:     Optional[int]					,     A					:     Optional[Any]					,     A					:     Dict						):
           _UpperCAmelCase      :     str        =   AlbertForMaskedLM(config=A						)
           model.to(A						)
           model.eval()
           _UpperCAmelCase      :     List[Any]        =   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 						snake_case_ (					self					:     Tuple					,     A					:     Optional[int]					,     A					:     Dict					,     A					:     List[Any]					,     A					:     Any					,     A					:     str					,     A					:     Optional[Any]					,     A					:     List[Any]						):
           _UpperCAmelCase      :     int        =   AlbertForQuestionAnswering(config=A						)
           model.to(A						)
           model.eval()
           _UpperCAmelCase      :     Tuple        =   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 						snake_case_ (					self					:     Dict					,     A					:     Optional[int]					,     A					:     List[str]					,     A					:     Dict					,     A					:     str					,     A					:     List[Any]					,     A					:     int					,     A					:     Optional[Any]						):
           _UpperCAmelCase      :     int        =   self.num_labels
           _UpperCAmelCase      :     str        =   AlbertForSequenceClassification(A						)
           model.to(A						)
           model.eval()
           _UpperCAmelCase      :     Tuple        =   model(A					,     attention_mask=A					,     token_type_ids=A					,     labels=A						)
           self.parent.assertEqual(result.logits.shape					,     (self.batch_size, self.num_labels)						)



      def 						snake_case_ (					self					:     Union[str, Any]					,     A					:     int					,     A					:     Optional[int]					,     A					:     int					,     A					:     List[Any]					,     A					:     Any					,     A					:     Tuple					,     A					:     Dict						):
           _UpperCAmelCase      :     Dict        =   self.num_labels
           _UpperCAmelCase      :     List[str]        =   AlbertForTokenClassification(config=A						)
           model.to(A						)
           model.eval()
           _UpperCAmelCase      :     Any        =   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 						snake_case_ (					self					:     Dict					,     A					:     int					,     A					:     int					,     A					:     Tuple					,     A					:     Any					,     A					:     str					,     A					:     Optional[int]					,     A					:     Optional[Any]						):
           _UpperCAmelCase      :     Dict        =   self.num_choices
           _UpperCAmelCase      :     Any        =   AlbertForMultipleChoice(config=A						)
           model.to(A						)
           model.eval()
           _UpperCAmelCase      :     Union[str, Any]        =   input_ids.unsqueeze(1						).expand(-1					,     self.num_choices					,     -1						).contiguous()
           _UpperCAmelCase      :     Optional[int]        =   token_type_ids.unsqueeze(1						).expand(-1					,     self.num_choices					,     -1						).contiguous()
           _UpperCAmelCase      :     Any        =   input_mask.unsqueeze(1						).expand(-1					,     self.num_choices					,     -1						).contiguous()
           _UpperCAmelCase      :     Any        =   model(
               A					,     attention_mask=A					,     token_type_ids=A					,     labels=A					,     )
           self.parent.assertEqual(result.logits.shape					,     (self.batch_size, self.num_choices)						)



      def 						snake_case_ (					self					:     Optional[Any]						):
           _UpperCAmelCase      :     List[Any]        =   self.prepare_config_and_inputs()
           (
               (
               _UpperCAmelCase
           )    ,	(
               _UpperCAmelCase
           )    ,	(
               _UpperCAmelCase
           )    ,	(
               _UpperCAmelCase
           )    ,	(
               _UpperCAmelCase
           )    ,	(
               _UpperCAmelCase
           )    ,	(
               _UpperCAmelCase
           )    ,	
           )      :     int        =   config_and_inputs
           _UpperCAmelCase      :     List[Any]        =   {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
           return config, inputs_dict







@require_torch
class      UpperCAmelCase_  (    _UpperCamelCase	,      _UpperCamelCase	,      unittest.TestCase						):
      __SCREAMING_SNAKE_CASE						:       List[str]								=			(
          (
              AlbertModel,
              AlbertForPreTraining,
              AlbertForMaskedLM,
              AlbertForMultipleChoice,
              AlbertForSequenceClassification,
              AlbertForTokenClassification,
              AlbertForQuestionAnswering,
          )
          if is_torch_available()
          else ()
      )
      __SCREAMING_SNAKE_CASE						:       List[str]								=			(
          {
              'feature-extraction': AlbertModel,
              'fill-mask': AlbertForMaskedLM,
              'question-answering': AlbertForQuestionAnswering,
              'text-classification': AlbertForSequenceClassification,
              'token-classification': AlbertForTokenClassification,
              'zero-shot': AlbertForSequenceClassification,
          }
          if is_torch_available()
          else {}
      )
      __SCREAMING_SNAKE_CASE						:       int								=			True



      def 						snake_case_ (					self					:     str					,     A					:     Tuple					,     A					:     int					,     A					:     Optional[Any]=False						):
           _UpperCAmelCase      :     List[Any]        =   super()._prepare_for_class(A					,     A					,     return_labels=A						)

           if return_labels:
                if model_class in get_values(A						):
                     _UpperCAmelCase      :     int        =   torch.zeros(
                         (self.model_tester.batch_size, self.model_tester.seq_length)					,     dtype=torch.long					,     device=A						)
                     _UpperCAmelCase      :     Union[str, Any]        =   torch.zeros(
                         self.model_tester.batch_size					,     dtype=torch.long					,     device=A						)
           return inputs_dict



      def 						snake_case_ (					self					:     Tuple						):
           _UpperCAmelCase      :     List[Any]        =   AlbertModelTester(self						)
           _UpperCAmelCase      :     List[str]        =   ConfigTester(self					,     config_class=A					,     hidden_size=3_7						)



      def 						snake_case_ (					self					:     Optional[int]						):
           self.config_tester.run_common_tests()



      def 						snake_case_ (					self					:     int						):
           _UpperCAmelCase      :     str        =   self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_model(*A						)



      def 						snake_case_ (					self					:     Optional[Any]						):
           _UpperCAmelCase      :     List[Any]        =   self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_pretraining(*A						)



      def 						snake_case_ (					self					:     Optional[Any]						):
           _UpperCAmelCase      :     Optional[Any]        =   self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_masked_lm(*A						)



      def 						snake_case_ (					self					:     Any						):
           _UpperCAmelCase      :     Optional[int]        =   self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_multiple_choice(*A						)



      def 						snake_case_ (					self					:     Union[str, Any]						):
           _UpperCAmelCase      :     Tuple        =   self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_question_answering(*A						)



      def 						snake_case_ (					self					:     Tuple						):
           _UpperCAmelCase      :     Union[str, Any]        =   self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_sequence_classification(*A						)



      def 						snake_case_ (					self					:     Union[str, Any]						):
           _UpperCAmelCase      :     List[str]        =   self.model_tester.prepare_config_and_inputs()
           for type in ["absolute", "relative_key", "relative_key_query"]:
                _UpperCAmelCase      :     int        =   type
                self.model_tester.create_and_check_model(*A						)



      @slow
      def 						snake_case_ (					self					:     Union[str, Any]						):
           for model_name in ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                _UpperCAmelCase      :     int        =   AlbertModel.from_pretrained(A						)
                self.assertIsNotNone(A						)







@require_torch
class      UpperCAmelCase_  (    unittest.TestCase						):



      @slow
      def 						snake_case_ (					self					:     Union[str, Any]						):
           _UpperCAmelCase      :     Optional[int]        =   AlbertModel.from_pretrained("albert-base-v2"						)
           _UpperCAmelCase      :     str        =   torch.tensor([[0, 3_4_5, 2_3_2, 3_2_8, 7_4_0, 1_4_0, 1_6_9_5, 6_9, 6_0_7_8, 1_5_8_8, 2]]						)
           _UpperCAmelCase      :     Tuple        =   torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]						)
           with torch.no_grad():
                _UpperCAmelCase      :     Union[str, Any]        =   model(A					,     attention_mask=A						)[0]
           _UpperCAmelCase      :     int        =   torch.Size((1, 1_1, 7_6_8)						)
           self.assertEqual(output.shape					,     A						)
           _UpperCAmelCase      :     List[str]        =   torch.tensor(
               [[[-0.6_513, 1.5_035, -0.2_766], [-0.6_515, 1.5_046, -0.2_780], [-0.6_512, 1.5_049, -0.2_784]]]						)

           self.assertTrue(torch.allclose(output[:, 1:4, 1:4]					,     A					,     atol=1e-4						)						)





"""simple docstring"""




def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Dict=28_123    )  ->       List[str]:





     '''simple docstring'''

     _UpperCAmelCase      :     List[Any]        =   [1] * (limit + 1)

     for i in range(2						,  int(limit**0.5    ) + 1    ):
          sum_divs[i * i] += i
          for k in range(i + 1						,  limit // i + 1    ):
               sum_divs[k * i] += k + i

     _UpperCAmelCase      :     Any        =   set()
     _UpperCAmelCase      :     List[str]        =   0

     for n in range(1						,  limit + 1    ):
          if sum_divs[n] > n:
               abundants.add(SCREAMING_SNAKE_CASE__    )

          if not any((n - a in abundants) for a in abundants    ):
               res += n

     return res


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