import json
import os
import shutil
import tempfile
import unittest

import numpy as np
import pytest

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


if is_vision_available():
   from PIL import Image

   from transformers import ChineseCLIPImageProcessor, ChineseCLIPProcessor







@require_vision
class   lowerCamelCase	(						unittest.TestCase						):





     def 	UpperCAmelCase(self   :					Optional[int]     )		->		Optional[Any]:
         snake_case				  =      tempfile.mkdtemp()

         snake_case				  =      [
             '''[UNK]''',
             '''[CLS]''',
             '''[SEP]''',
             '''[PAD]''',
             '''[MASK]''',
             '''的''',
             '''价''',
             '''格''',
             '''是''',
             '''15''',
             '''便''',
             '''alex''',
             '''##andra''',
             '''，''',
             '''。''',
             '''-''',
             '''t''',
             '''shirt''',
         ]
         snake_case				  =      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]     )     )

         snake_case				  =      {
             '''do_resize''': True,
             '''size''': {'''height''': 2_2_4, '''width''': 2_2_4},
             '''do_center_crop''': True,
             '''crop_size''': {'''height''': 1_8, '''width''': 1_8},
             '''do_normalize''': True,
             '''image_mean''': [0.48_14_54_66, 0.4_57_82_75, 0.40_82_10_73],
             '''image_std''': [0.26_86_29_54, 0.26_13_02_58, 0.27_57_77_11],
             '''do_convert_rgb''': True,
         }
         snake_case				  =      os.path.join(self.tmpdirname       ,					UpperCamelCase__     )
         with open(self.image_processor_file       ,					"w"       ,					encoding="utf-8"     ) as fp:
             json.dump(UpperCamelCase__       ,					UpperCamelCase__     )





     def 	UpperCAmelCase(self   :					List[Any]       ,					**_A   :					Optional[Any]     )		->		Tuple:
         return BertTokenizer.from_pretrained(self.tmpdirname       ,					**UpperCamelCase__     )





     def 	UpperCAmelCase(self   :					Optional[int]       ,					**_A   :					Optional[Any]     )		->		Optional[Any]:
         return BertTokenizerFast.from_pretrained(self.tmpdirname       ,					**UpperCamelCase__     )





     def 	UpperCAmelCase(self   :					int       ,					**_A   :					List[Any]     )		->		Optional[Any]:
         return ChineseCLIPImageProcessor.from_pretrained(self.tmpdirname       ,					**UpperCamelCase__     )





     def 	UpperCAmelCase(self   :					Tuple     )		->		List[str]:
         shutil.rmtree(self.tmpdirname     )





     def 	UpperCAmelCase(self   :					str     )		->		Optional[int]:
         snake_case				  =      [np.random.randint(2_5_5       ,					size=(3, 3_0, 4_0_0)       ,					dtype=np.uinta     )]

         snake_case				  =      [Image.fromarray(np.moveaxis(UpperCamelCase__       ,					0       ,					-1     )     ) for x in image_inputs]

         return image_inputs





     def 	UpperCAmelCase(self   :					Tuple     )		->		Tuple:
         snake_case				  =      self.get_tokenizer()
         snake_case				  =      self.get_rust_tokenizer()
         snake_case				  =      self.get_image_processor()

         snake_case				  =      ChineseCLIPProcessor(tokenizer=UpperCamelCase__       ,					image_processor=UpperCamelCase__     )
         processor_slow.save_pretrained(self.tmpdirname     )
         snake_case				  =      ChineseCLIPProcessor.from_pretrained(self.tmpdirname       ,					use_fast=UpperCamelCase__     )

         snake_case				  =      ChineseCLIPProcessor(tokenizer=UpperCamelCase__       ,					image_processor=UpperCamelCase__     )
         processor_fast.save_pretrained(self.tmpdirname     )
         snake_case				  =      ChineseCLIPProcessor.from_pretrained(self.tmpdirname     )

         self.assertEqual(processor_slow.tokenizer.get_vocab()       ,					tokenizer_slow.get_vocab()     )
         self.assertEqual(processor_fast.tokenizer.get_vocab()       ,					tokenizer_fast.get_vocab()     )
         self.assertEqual(tokenizer_slow.get_vocab()       ,					tokenizer_fast.get_vocab()     )
         self.assertIsInstance(processor_slow.tokenizer       ,					UpperCamelCase__     )
         self.assertIsInstance(processor_fast.tokenizer       ,					UpperCamelCase__     )

         self.assertEqual(processor_slow.image_processor.to_json_string()       ,					image_processor.to_json_string()     )
         self.assertEqual(processor_fast.image_processor.to_json_string()       ,					image_processor.to_json_string()     )
         self.assertIsInstance(processor_slow.image_processor       ,					UpperCamelCase__     )
         self.assertIsInstance(processor_fast.image_processor       ,					UpperCamelCase__     )





     def 	UpperCAmelCase(self   :					Any     )		->		List[Any]:
         snake_case				  =      ChineseCLIPProcessor(tokenizer=self.get_tokenizer()       ,					image_processor=self.get_image_processor()     )
         processor.save_pretrained(self.tmpdirname     )

         snake_case				  =      self.get_tokenizer(cls_token="(CLS)"       ,					sep_token="(SEP)"     )
         snake_case				  =      self.get_image_processor(do_normalize=UpperCamelCase__     )

         snake_case				  =      ChineseCLIPProcessor.from_pretrained(
             self.tmpdirname       ,					cls_token="(CLS)"       ,					sep_token="(SEP)"       ,					do_normalize=UpperCamelCase__     )

         self.assertEqual(processor.tokenizer.get_vocab()       ,					tokenizer_add_kwargs.get_vocab()     )
         self.assertIsInstance(processor.tokenizer       ,					UpperCamelCase__     )

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





     def 	UpperCAmelCase(self   :					List[Any]     )		->		int:
         snake_case				  =      self.get_image_processor()
         snake_case				  =      self.get_tokenizer()

         snake_case				  =      ChineseCLIPProcessor(tokenizer=UpperCamelCase__       ,					image_processor=UpperCamelCase__     )

         snake_case				  =      self.prepare_image_inputs()

         snake_case				  =      image_processor(UpperCamelCase__       ,					return_tensors="np"     )
         snake_case				  =      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 	UpperCAmelCase(self   :					Optional[int]     )		->		str:
         snake_case				  =      self.get_image_processor()
         snake_case				  =      self.get_tokenizer()

         snake_case				  =      ChineseCLIPProcessor(tokenizer=UpperCamelCase__       ,					image_processor=UpperCamelCase__     )

         snake_case				  =      '''Alexandra，T-shirt的价格是15便士。'''

         snake_case				  =      processor(text=UpperCamelCase__     )

         snake_case				  =      tokenizer(UpperCamelCase__     )

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





     def 	UpperCAmelCase(self   :					List[Any]     )		->		int:
         snake_case				  =      self.get_image_processor()
         snake_case				  =      self.get_tokenizer()

         snake_case				  =      ChineseCLIPProcessor(tokenizer=UpperCamelCase__       ,					image_processor=UpperCamelCase__     )

         snake_case				  =      '''Alexandra，T-shirt的价格是15便士。'''
         snake_case				  =      self.prepare_image_inputs()

         snake_case				  =      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 pytest.raises(UpperCamelCase__     ):
             processor()





     def 	UpperCAmelCase(self   :					List[str]     )		->		int:
         snake_case				  =      self.get_image_processor()
         snake_case				  =      self.get_tokenizer()

         snake_case				  =      ChineseCLIPProcessor(tokenizer=UpperCamelCase__       ,					image_processor=UpperCamelCase__     )

         snake_case				  =      [[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

         snake_case				  =      processor.batch_decode(UpperCamelCase__     )
         snake_case				  =      tokenizer.batch_decode(UpperCamelCase__     )

         self.assertListEqual(UpperCamelCase__       ,					UpperCamelCase__     )





     def 	UpperCAmelCase(self   :					Optional[int]     )		->		Dict:
         snake_case				  =      self.get_image_processor()
         snake_case				  =      self.get_tokenizer()

         snake_case				  =      ChineseCLIPProcessor(tokenizer=UpperCamelCase__       ,					image_processor=UpperCamelCase__     )

         snake_case				  =      '''Alexandra，T-shirt的价格是15便士。'''
         snake_case				  =      self.prepare_image_inputs()

         snake_case				  =      processor(text=UpperCamelCase__       ,					images=UpperCamelCase__     )

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



import sys

_A						      =				(
    "73167176531330624919225119674426574742355349194934"
    "96983520312774506326239578318016984801869478851843"
    "85861560789112949495459501737958331952853208805511"
    "12540698747158523863050715693290963295227443043557"
    "66896648950445244523161731856403098711121722383113"
    "62229893423380308135336276614282806444486645238749"
    "30358907296290491560440772390713810515859307960866"
    "70172427121883998797908792274921901699720888093776"
    "65727333001053367881220235421809751254540594752243"
    "52584907711670556013604839586446706324415722155397"
    "53697817977846174064955149290862569321978468622482"
    "83972241375657056057490261407972968652414535100474"
    "82166370484403199890008895243450658541227588666881"
    "16427171479924442928230863465674813919123162824586"
    "17866458359124566529476545682848912883142607690042"
    "24219022671055626321111109370544217506941658960408"
    "07198403850962455444362981230987879927244284909188"
    "84580156166097919133875499200524063689912560717606"
    "05886116467109405077541002256983155200055935729725"
    "71636269561882670428252483600823257530420752963450"
)



def 		lowercase_    (     A__	)							->							int:
    """simple docstring"""

    snake_case				  =      1
    for digit in s:
        product *= int(A__	)
    return product



def 		lowercase_    (     A__ = N	)							->							int:
    """simple docstring"""

    snake_case				  =      -sys.maxsize - 1
    snake_case				  =      n[:13]
    snake_case				  =      13
    while cur_index < len(A__	) - 13:
        if int(n[cur_index]	) >= int(substr[0]	):
            snake_case				  =      substr[1:] + n[cur_index]
            cur_index += 1
        else:
            snake_case				  =      max(A__				,	str_eval(A__	)	)
            snake_case				  =      n[cur_index : cur_index + 13]
            cur_index += 13
    return largest_product


if __name__ == "__main__":
   print(f"{solution() = }")

