"""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  _snake_case     (					unittest.TestCase		):






      def       lowerCamelCase__     (       self      :			List[Any]    ):
             __lowerCamelCase					:		Optional[int]		   =     tempfile.mkdtemp()

             # fmt: off
             __lowerCamelCase					:		Optional[Any]		   =     ["[UNK]", "[CLS]", "[SEP]", "[PAD]", "[MASK]", "want", "##want", "##ed", "wa", "un", "runn", "##ing", ",", "low", "lowest"]
             # fmt: on
             __lowerCamelCase					:		Tuple		   =     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]    )    )

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






      def       lowerCamelCase__     (       self      :			List[str]							,					**UpperCAmelCase      :			Optional[Any]    ):
             return BertTokenizer.from_pretrained(self.tmpdirname							,					**UpperCAmelCase    )






      def       lowerCamelCase__     (       self      :			Dict							,					**UpperCAmelCase      :			Union[str, Any]    ):
             return ViTImageProcessor.from_pretrained(self.tmpdirname							,					**UpperCAmelCase    )






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






      def       lowerCamelCase__     (       self      :			Any    ):
             __lowerCamelCase					:		str		   =     [np.random.randint(255							,					size=(3, 30, 400)							,					dtype=np.uinta    )]

             __lowerCamelCase					:		Optional[int]		   =     [Image.fromarray(np.moveaxis(UpperCAmelCase							,					0							,					-1    )    ) for x in image_inputs]

             return image_inputs






      def       lowerCamelCase__     (       self      :			Tuple    ):
             __lowerCamelCase					:		Optional[int]		   =     self.get_tokenizer()
             __lowerCamelCase					:		Optional[Any]		   =     self.get_image_processor()

             __lowerCamelCase					:		str		   =     VisionTextDualEncoderProcessor(tokenizer=UpperCAmelCase							,					image_processor=UpperCAmelCase    )

             processor.save_pretrained(self.tmpdirname    )
             __lowerCamelCase					:		str		   =     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							,					UpperCAmelCase    )






      def       lowerCamelCase__     (       self      :			int    ):
             __lowerCamelCase					:		Any		   =     VisionTextDualEncoderProcessor(
                 tokenizer=self.get_tokenizer()							,					image_processor=self.get_image_processor()    )
             processor.save_pretrained(self.tmpdirname    )

             __lowerCamelCase					:		Union[str, Any]		   =     self.get_tokenizer(bos_token="(BOS)"							,					eos_token="(EOS)"    )
             __lowerCamelCase					:		Union[str, Any]		   =     self.get_image_processor(do_normalize=UpperCAmelCase							,					padding_value=1.0    )

             __lowerCamelCase					:		Tuple		   =     VisionTextDualEncoderProcessor.from_pretrained(
                 self.tmpdirname							,					bos_token="(BOS)"							,					eos_token="(EOS)"							,					do_normalize=UpperCAmelCase							,					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							,					UpperCAmelCase    )






      def       lowerCamelCase__     (       self      :			Optional[Any]    ):
             __lowerCamelCase					:		Tuple		   =     self.get_image_processor()
             __lowerCamelCase					:		Dict		   =     self.get_tokenizer()

             __lowerCamelCase					:		int		   =     VisionTextDualEncoderProcessor(tokenizer=UpperCAmelCase							,					image_processor=UpperCAmelCase    )

             __lowerCamelCase					:		int		   =     self.prepare_image_inputs()

             __lowerCamelCase					:		Optional[Any]		   =     image_processor(UpperCAmelCase							,					return_tensors="np"    )
             __lowerCamelCase					:		int		   =     processor(images=UpperCAmelCase							,					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       lowerCamelCase__     (       self      :			Optional[Any]    ):
             __lowerCamelCase					:		Union[str, Any]		   =     self.get_image_processor()
             __lowerCamelCase					:		Any		   =     self.get_tokenizer()

             __lowerCamelCase					:		Tuple		   =     VisionTextDualEncoderProcessor(tokenizer=UpperCAmelCase							,					image_processor=UpperCAmelCase    )

             __lowerCamelCase					:		Union[str, Any]		   =     "lower newer"

             __lowerCamelCase					:		Union[str, Any]		   =     processor(text=UpperCAmelCase    )

             __lowerCamelCase					:		Tuple		   =     tokenizer(UpperCAmelCase    )

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






      def       lowerCamelCase__     (       self      :			Union[str, Any]    ):
             __lowerCamelCase					:		Tuple		   =     self.get_image_processor()
             __lowerCamelCase					:		Any		   =     self.get_tokenizer()

             __lowerCamelCase					:		Optional[int]		   =     VisionTextDualEncoderProcessor(tokenizer=UpperCAmelCase							,					image_processor=UpperCAmelCase    )

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

             __lowerCamelCase					:		List[str]		   =     processor(text=UpperCAmelCase							,					images=UpperCAmelCase    )

             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(UpperCAmelCase    ):
                    processor()






      def       lowerCamelCase__     (       self      :			Any    ):
             __lowerCamelCase					:		str		   =     self.get_image_processor()
             __lowerCamelCase					:		Any		   =     self.get_tokenizer()

             __lowerCamelCase					:		int		   =     VisionTextDualEncoderProcessor(tokenizer=UpperCAmelCase							,					image_processor=UpperCAmelCase    )

             __lowerCamelCase					:		Optional[Any]		   =     [[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

             __lowerCamelCase					:		List[Any]		   =     processor.batch_decode(UpperCAmelCase    )
             __lowerCamelCase					:		Union[str, Any]		   =     tokenizer.batch_decode(UpperCAmelCase    )

             self.assertListEqual(UpperCAmelCase							,					UpperCAmelCase    )







      def       lowerCamelCase__     (       self      :			List[Any]    ):
             __lowerCamelCase					:		List[str]		   =     self.get_image_processor()
             __lowerCamelCase					:		List[str]		   =     self.get_tokenizer()

             __lowerCamelCase					:		Dict		   =     VisionTextDualEncoderProcessor(tokenizer=UpperCAmelCase							,					image_processor=UpperCAmelCase    )

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

             __lowerCamelCase					:		Tuple		   =     processor(text=UpperCAmelCase							,					images=UpperCAmelCase    )

             self.assertListEqual(list(inputs.keys()    )							,					processor.model_input_names    )
"""simple docstring"""





from functools import lru_cache


def    lowercase_   (   _lowerCamelCase:	int      ) ->      set:



							'''simple docstring'''

							__lowerCamelCase					:		Optional[Any]		   =     2
							__lowerCamelCase					:		Tuple		   =     set()
							while i * i <= n:
														if n % i:
																					i += 1
														else:
																					n //= i
																					factors.add(_lowerCamelCase      )
							if n > 1:
														factors.add(_lowerCamelCase      )
							return factors


@lru_cache
def    lowercase_   (   _lowerCamelCase:	int      ) ->      int:



							'''simple docstring'''

							return len(unique_prime_factors(_lowerCamelCase      )      )


def    lowercase_   (   _lowerCamelCase:	list      ) ->      bool:



							'''simple docstring'''

							return len(set(_lowerCamelCase      )      ) in (0, 1)


def    lowercase_   (   _lowerCamelCase:	int      ) ->      list:



							'''simple docstring'''

							__lowerCamelCase					:		str		   =     2

							while True:
														# Increment each value of a generated range
														__lowerCamelCase					:		int		   =     [base + i for i in range(_lowerCamelCase      )]

														# Run elements through out unique_prime_factors function
														# Append our target number to the end.
														__lowerCamelCase					:		Dict		   =     [upf_len(_lowerCamelCase      ) for x in group]
														checker.append(_lowerCamelCase      )

														# If all numbers in the list are equal, return the group variable.
														if equality(_lowerCamelCase      ):
																					return group

														# Increment our base variable by 1
														base += 1


def    lowercase_   (   _lowerCamelCase:	int = 4      ) ->      int:



							'''simple docstring'''

							__lowerCamelCase					:		Any		   =     run(_lowerCamelCase      )
							return results[0] if len(_lowerCamelCase      ) else None


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