






'''simple docstring'''
from __future__ import annotations

import unittest

from transformers import AutoTokenizer, MBartConfig, is_tf_available
from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow
from transformers.utils import cached_property

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
     import tensorflow as tf

     from transformers import TFAutoModelForSeqaSeqLM, TFMBartForConditionalGeneration, TFMBartModel






@require_tf
class        __SCREAMING_SNAKE_CASE :
 snake_case_												=							MBartConfig
 snake_case_												=							{}
 snake_case_												=							"gelu"




 def __init__( self		:							List[str]   , __lowercase		:							Optional[int]   , __lowercase		:							Any=13   , __lowercase		:							Optional[Any]=7   , __lowercase		:							Union[str, Any]=True   , __lowercase		:							Tuple=False   , __lowercase		:							Any=99   , __lowercase		:							List[Any]=32   , __lowercase		:							Tuple=2   , __lowercase		:							Optional[int]=4   , __lowercase		:							List[str]=37   , __lowercase		:							Any=0.1   , __lowercase		:							List[Any]=0.1   , __lowercase		:							List[Any]=20   , __lowercase		:							int=2   , __lowercase		:							Optional[int]=1   , __lowercase		:							Any=0   , )		->  Union[str, Any]:
       SCREAMING_SNAKE_CASE__       :			List[Any]													=parent
       SCREAMING_SNAKE_CASE__       :			Tuple													=batch_size
       SCREAMING_SNAKE_CASE__       :			Any													=seq_length
       SCREAMING_SNAKE_CASE__       :			Tuple													=is_training
       SCREAMING_SNAKE_CASE__       :			Any													=use_labels
       SCREAMING_SNAKE_CASE__       :			List[Any]													=vocab_size
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=hidden_size
       SCREAMING_SNAKE_CASE__       :			Any													=num_hidden_layers
       SCREAMING_SNAKE_CASE__       :			str													=num_attention_heads
       SCREAMING_SNAKE_CASE__       :			Tuple													=intermediate_size
       SCREAMING_SNAKE_CASE__       :			Optional[int]													=hidden_dropout_prob
       SCREAMING_SNAKE_CASE__       :			Dict													=attention_probs_dropout_prob
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=max_position_embeddings
       SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=eos_token_id
       SCREAMING_SNAKE_CASE__       :			Any													=pad_token_id
       SCREAMING_SNAKE_CASE__       :			Any													=bos_token_id




 def        __magic_name__		( self		:							Any )		->  Dict:
       SCREAMING_SNAKE_CASE__       :			Any													=ids_tensor([self.batch_size, self.seq_length - 1]   , self.vocab_size )
       SCREAMING_SNAKE_CASE__       :			List[Any]													=tf.expand_dims(tf.constant([self.eos_token_id] * self.batch_size )   , 1 )
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=tf.concat([input_ids, eos_tensor]   , axis=1 )

       SCREAMING_SNAKE_CASE__       :			str													=ids_tensor([self.batch_size, self.seq_length]   , self.vocab_size )

       SCREAMING_SNAKE_CASE__       :			Any													=self.config_cls(
           vocab_size=self.vocab_size   , d_model=self.hidden_size   , encoder_layers=self.num_hidden_layers   , decoder_layers=self.num_hidden_layers   , encoder_attention_heads=self.num_attention_heads   , decoder_attention_heads=self.num_attention_heads   , encoder_ffn_dim=self.intermediate_size   , decoder_ffn_dim=self.intermediate_size   , dropout=self.hidden_dropout_prob   , attention_dropout=self.attention_probs_dropout_prob   , max_position_embeddings=self.max_position_embeddings   , eos_token_ids=[2]   , bos_token_id=self.bos_token_id   , pad_token_id=self.pad_token_id   , decoder_start_token_id=self.pad_token_id   , **self.config_updates   , )
       SCREAMING_SNAKE_CASE__       :			List[Any]													=prepare_mbart_inputs_dict(__UpperCAmelCase   , __UpperCAmelCase   , __UpperCAmelCase )
       return config, inputs_dict




 def        __magic_name__		( self		:							Optional[int]   , __lowercase		:							Optional[int]   , __lowercase		:							Tuple )		->  int:
       SCREAMING_SNAKE_CASE__       :			Dict													=TFMBartModel(config=__UpperCAmelCase ).get_decoder()
       SCREAMING_SNAKE_CASE__       :			Dict													=inputs_dict["""input_ids"""]

       SCREAMING_SNAKE_CASE__       :			List[str]													=input_ids[:1, :]
       SCREAMING_SNAKE_CASE__       :			Any													=inputs_dict["""attention_mask"""][:1, :]
       SCREAMING_SNAKE_CASE__       :			Tuple													=inputs_dict["""head_mask"""]
       SCREAMING_SNAKE_CASE__       :			Tuple													=1

       # first forward pass
       SCREAMING_SNAKE_CASE__       :			Tuple													=model(__UpperCAmelCase   , attention_mask=__UpperCAmelCase   , head_mask=__UpperCAmelCase   , use_cache=__UpperCAmelCase )

       SCREAMING_SNAKE_CASE__       :			Optional[int]													=outputs.to_tuple()
       SCREAMING_SNAKE_CASE__       :			str													=past_key_values[1]





def 	_a(					UpperCamelCase__			:  Union[str, Any],		UpperCamelCase__			:  List[Any],		UpperCamelCase__			:  Optional[int],		UpperCamelCase__			:  List[Any]=None,		UpperCamelCase__			:  Union[str, Any]=None,		UpperCamelCase__			:  Optional[Any]=None,		UpperCamelCase__			:  List[Any]=None,		UpperCamelCase__			:  str=None,		):




      '''simple docstring'''






      if attention_mask is None:
            SCREAMING_SNAKE_CASE__       :			Any													=tf.cast(tf.math.not_equal(lowerCAmelCase__,		config.pad_token_id							),		tf.inta							)
      if decoder_attention_mask is None:
            SCREAMING_SNAKE_CASE__       :			Optional[int]													=tf.concat(
                [
                    tf.ones(decoder_input_ids[:, :1].shape,		dtype=tf.inta							),
                    tf.cast(tf.math.not_equal(decoder_input_ids[:, 1:],		config.pad_token_id							),		tf.inta							),
                ],		axis=-1,		)
      if head_mask is None:
            SCREAMING_SNAKE_CASE__       :			Any													=tf.ones((config.encoder_layers, config.encoder_attention_heads)							)
      if decoder_head_mask is None:
            SCREAMING_SNAKE_CASE__       :			Optional[int]													=tf.ones((config.decoder_layers, config.decoder_attention_heads)							)
      if cross_attn_head_mask is None:
            SCREAMING_SNAKE_CASE__       :			List[Any]													=tf.ones((config.decoder_layers, config.decoder_attention_heads)							)
      return {
          "input_ids": input_ids,
          "decoder_input_ids": decoder_input_ids,
          "attention_mask": attention_mask,
          "decoder_attention_mask": decoder_attention_mask,
          "head_mask": head_mask,
          "decoder_head_mask": decoder_head_mask,
          "cross_attn_head_mask": cross_attn_head_mask,
      }






@require_tf
class        __SCREAMING_SNAKE_CASE (     __SCREAMING_SNAKE_CASE		,			__SCREAMING_SNAKE_CASE		,			unittest.TestCase			):
 snake_case_												=							(TFMBartForConditionalGeneration, TFMBartModel) if is_tf_available() else ()
 snake_case_												=							(TFMBartForConditionalGeneration,) if is_tf_available() else ()
 snake_case_												=							(
     {
         "conversational": TFMBartForConditionalGeneration,
         "feature-extraction": TFMBartModel,
         "summarization": TFMBartForConditionalGeneration,
         "text2text-generation": TFMBartForConditionalGeneration,
         "translation": TFMBartForConditionalGeneration,
     }
     if is_tf_available()
     else {}
 )
 snake_case_												=							True
 snake_case_												=							False
 snake_case_												=							False




 def        __magic_name__		( self		:							str   , __lowercase		:							int   , __lowercase		:							str   , __lowercase		:							List[str]   , __lowercase		:							Union[str, Any]   , __lowercase		:							str )		->  Union[str, Any]:
       if pipeline_test_casse_name != "FeatureExtractionPipelineTests":
             # Exception encountered when calling layer '...'
             return True

       return False




 def        __magic_name__		( self		:							Union[str, Any] )		->  List[Any]:
       SCREAMING_SNAKE_CASE__       :			Optional[int]													=TFMBartModelTester(self )
       SCREAMING_SNAKE_CASE__       :			int													=ConfigTester(self   , config_class=__UpperCAmelCase )




 def        __magic_name__		( self		:							Optional[Any] )		->  Union[str, Any]:
       self.config_tester.run_common_tests()




 def        __magic_name__		( self		:							Tuple )		->  Tuple:
       SCREAMING_SNAKE_CASE__       :			List[Any]													=self.model_tester.prepare_config_and_inputs_for_common()
       self.model_tester.check_decoder_model_past_large_inputs(*__UpperCAmelCase )






@require_sentencepiece
@require_tokenizers
@require_tf
class        __SCREAMING_SNAKE_CASE (     unittest.TestCase			):
 snake_case_												=							[
     " UN Chief Says There Is No Military Solution in Syria",
 ]
 snake_case_												=							[
     "Şeful ONU declară că nu există o soluţie militară în Siria",
 ]
 snake_case_												=							"facebook/mbart-large-en-ro"




 @cached_property
 def        __magic_name__		( self		:							Optional[Any] )		->  int:
       return AutoTokenizer.from_pretrained(self.model_name )




 @cached_property
 def        __magic_name__		( self		:							Optional[Any] )		->  Union[str, Any]:
       SCREAMING_SNAKE_CASE__       :			Any													=TFAutoModelForSeqaSeqLM.from_pretrained(self.model_name )
       return model




 def        __magic_name__		( self		:							Dict   , **__lowercase		:							List[Any] )		->  Any:
       SCREAMING_SNAKE_CASE__       :			Optional[Any]													=self.translate_src_text(**__UpperCAmelCase )
       self.assertListEqual(self.expected_text   , __UpperCAmelCase )




 def        __magic_name__		( self		:							List[Any]   , **__lowercase		:							Union[str, Any] )		->  Union[str, Any]:
       SCREAMING_SNAKE_CASE__       :			Any													=self.tokenizer(self.src_text   , **__UpperCAmelCase   , return_tensors='''tf''' )
       SCREAMING_SNAKE_CASE__       :			Any													=self.model.generate(
           model_inputs.input_ids   , attention_mask=model_inputs.attention_mask   , num_beams=2 )
       SCREAMING_SNAKE_CASE__       :			Dict													=self.tokenizer.batch_decode(__UpperCAmelCase   , skip_special_tokens=__UpperCAmelCase )
       return generated_words




 @slow
 def        __magic_name__		( self		:							Dict )		->  Tuple:
       self._assert_generated_batch_equal_expected()







'''simple docstring'''
def 	_a(					UpperCamelCase__			:  Optional[Any]=2_8_1_2_3							):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__       :			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

      SCREAMING_SNAKE_CASE__       :			List[str]													=set()
      SCREAMING_SNAKE_CASE__       :			str													=0

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

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

      return res


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