



"""simple docstring"""




import json
import os
import shutil
import tempfile
import unittest

import numpy as np

from transformers import BertTokenizerFast
from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer
from transformers.testing_utils import require_tokenizers, require_vision
from transformers.utils import IMAGE_PROCESSOR_NAME, is_vision_available


if is_vision_available():
 from PIL import Image

 from transformers import VisionTextDualEncoderProcessor, ViTImageProcessor






@require_tokenizers
@require_vision
class      UpperCAmelCase_  (    unittest.TestCase						):



      def 						snake_case_ (					self					:     Dict						):
           _UpperCAmelCase      :     Tuple        =   tempfile.mkdtemp()

           # fmt: off
           _UpperCAmelCase      :     Tuple        =   ["[UNK]", "[CLS]", "[SEP]", "[PAD]", "[MASK]", "want", "##want", "##ed", "wa", "un", "runn", "##ing", ",", "low", "lowest"]
           # fmt: on
           _UpperCAmelCase      :     Any        =   os.path.join(self.tmpdirname					,     VOCAB_FILES_NAMES["vocab_file"]						)
           with open(self.vocab_file					,     "w"					,     encoding="utf-8"						) as vocab_writer:
                vocab_writer.write("".join([x + "\n" for x in vocab_tokens]						)						)

           _UpperCAmelCase      :     Any        =   {
               "do_resize": True,
               "size": {"height": 1_8, "width": 1_8},
               "do_normalize": True,
               "image_mean": [0.5, 0.5, 0.5],
               "image_std": [0.5, 0.5, 0.5],
           }
           _UpperCAmelCase      :     List[str]        =   os.path.join(self.tmpdirname					,     A						)
           with open(self.image_processor_file					,     "w"					,     encoding="utf-8"						) as fp:
                json.dump(A					,     A						)



      def 						snake_case_ (					self					:     Dict					,     **A					:     List[Any]						):
           return BertTokenizer.from_pretrained(self.tmpdirname					,     **A						)



      def 						snake_case_ (					self					:     Tuple					,     **A					:     Tuple						):
           return ViTImageProcessor.from_pretrained(self.tmpdirname					,     **A						)



      def 						snake_case_ (					self					:     Dict						):
           shutil.rmtree(self.tmpdirname						)



      def 						snake_case_ (					self					:     List[Any]						):
           _UpperCAmelCase      :     Optional[Any]        =   [np.random.randint(2_5_5					,     size=(3, 3_0, 4_0_0)					,     dtype=np.uinta						)]

           _UpperCAmelCase      :     Union[str, Any]        =   [Image.fromarray(np.moveaxis(A					,     0					,     -1						)						) for x in image_inputs]

           return image_inputs



      def 						snake_case_ (					self					:     Optional[int]						):
           _UpperCAmelCase      :     Any        =   self.get_tokenizer()
           _UpperCAmelCase      :     Optional[int]        =   self.get_image_processor()

           _UpperCAmelCase      :     Dict        =   VisionTextDualEncoderProcessor(tokenizer=A					,     image_processor=A						)

           processor.save_pretrained(self.tmpdirname						)
           _UpperCAmelCase      :     Tuple        =   VisionTextDualEncoderProcessor.from_pretrained(self.tmpdirname						)

           self.assertEqual(processor.tokenizer.get_vocab()					,     tokenizer.get_vocab()						)
           self.assertIsInstance(processor.tokenizer					,     (BertTokenizer, BertTokenizerFast)						)

           self.assertEqual(processor.image_processor.to_json_string()					,     image_processor.to_json_string()						)
           self.assertIsInstance(processor.image_processor					,     A						)



      def 						snake_case_ (					self					:     List[Any]						):
           _UpperCAmelCase      :     Union[str, Any]        =   VisionTextDualEncoderProcessor(
               tokenizer=self.get_tokenizer()					,     image_processor=self.get_image_processor()						)
           processor.save_pretrained(self.tmpdirname						)

           _UpperCAmelCase      :     Tuple        =   self.get_tokenizer(bos_token="(BOS)"					,     eos_token="(EOS)"						)
           _UpperCAmelCase      :     Optional[Any]        =   self.get_image_processor(do_normalize=A					,     padding_value=1.0						)

           _UpperCAmelCase      :     Dict        =   VisionTextDualEncoderProcessor.from_pretrained(
               self.tmpdirname					,     bos_token="(BOS)"					,     eos_token="(EOS)"					,     do_normalize=A					,     padding_value=1.0						)

           self.assertEqual(processor.tokenizer.get_vocab()					,     tokenizer_add_kwargs.get_vocab()						)
           self.assertIsInstance(processor.tokenizer					,     (BertTokenizer, BertTokenizerFast)						)

           self.assertEqual(processor.image_processor.to_json_string()					,     image_processor_add_kwargs.to_json_string()						)
           self.assertIsInstance(processor.image_processor					,     A						)



      def 						snake_case_ (					self					:     Optional[int]						):
           _UpperCAmelCase      :     Tuple        =   self.get_image_processor()
           _UpperCAmelCase      :     Union[str, Any]        =   self.get_tokenizer()

           _UpperCAmelCase      :     int        =   VisionTextDualEncoderProcessor(tokenizer=A					,     image_processor=A						)

           _UpperCAmelCase      :     Dict        =   self.prepare_image_inputs()

           _UpperCAmelCase      :     int        =   image_processor(A					,     return_tensors="np"						)
           _UpperCAmelCase      :     int        =   processor(images=A					,     return_tensors="np"						)

           for key in input_feat_extract.keys():
                self.assertAlmostEqual(input_feat_extract[key].sum()					,     input_processor[key].sum()					,     delta=1e-2						)



      def 						snake_case_ (					self					:     int						):
           _UpperCAmelCase      :     List[str]        =   self.get_image_processor()
           _UpperCAmelCase      :     List[Any]        =   self.get_tokenizer()

           _UpperCAmelCase      :     List[Any]        =   VisionTextDualEncoderProcessor(tokenizer=A					,     image_processor=A						)

           _UpperCAmelCase      :     int        =   "lower newer"

           _UpperCAmelCase      :     str        =   processor(text=A						)

           _UpperCAmelCase      :     str        =   tokenizer(A						)

           for key in encoded_tok.keys():
                self.assertListEqual(encoded_tok[key]					,     encoded_processor[key]						)



      def 						snake_case_ (					self					:     List[Any]						):
           _UpperCAmelCase      :     int        =   self.get_image_processor()
           _UpperCAmelCase      :     Any        =   self.get_tokenizer()

           _UpperCAmelCase      :     Union[str, Any]        =   VisionTextDualEncoderProcessor(tokenizer=A					,     image_processor=A						)

           _UpperCAmelCase      :     Union[str, Any]        =   "lower newer"
           _UpperCAmelCase      :     str        =   self.prepare_image_inputs()

           _UpperCAmelCase      :     List[str]        =   processor(text=A					,     images=A						)

           self.assertListEqual(list(inputs.keys()						)					,     ["input_ids", "token_type_ids", "attention_mask", "pixel_values"]						)

           # test if it raises when no input is passed
           with self.assertRaises(A						):
                processor()



      def 						snake_case_ (					self					:     Dict						):
           _UpperCAmelCase      :     Tuple        =   self.get_image_processor()
           _UpperCAmelCase      :     Any        =   self.get_tokenizer()

           _UpperCAmelCase      :     List[str]        =   VisionTextDualEncoderProcessor(tokenizer=A					,     image_processor=A						)

           _UpperCAmelCase      :     Union[str, Any]        =   [[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

           _UpperCAmelCase      :     str        =   processor.batch_decode(A						)
           _UpperCAmelCase      :     int        =   tokenizer.batch_decode(A						)

           self.assertListEqual(A					,     A						)



      def 						snake_case_ (					self					:     Optional[int]						):
           _UpperCAmelCase      :     int        =   self.get_image_processor()
           _UpperCAmelCase      :     Optional[int]        =   self.get_tokenizer()

           _UpperCAmelCase      :     Tuple        =   VisionTextDualEncoderProcessor(tokenizer=A					,     image_processor=A						)

           _UpperCAmelCase      :     int        =   "lower newer"
           _UpperCAmelCase      :     Optional[Any]        =   self.prepare_image_inputs()

           _UpperCAmelCase      :     Any        =   processor(text=A					,     images=A						)

           self.assertListEqual(list(inputs.keys()						)					,     processor.model_input_names						)





"""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())
