
"""simple docstring"""






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 IMAGE_PROCESSOR_NAME, is_vision_available


if is_vision_available():
    from PIL import Image

    from transformers import AlignProcessor, EfficientNetImageProcessor



@require_vision
class 	lowerCAmelCase					(      unittest.TestCase							):






       def 							__A (   self     ):
              _UpperCAmelCase     =     tempfile.mkdtemp()

              _UpperCAmelCase     =     [
                  '[UNK]',
                  '[CLS]',
                  '[SEP]',
                  '[PAD]',
                  '[MASK]',
                  'want',
                  '##want',
                  '##ed',
                  'wa',
                  'un',
                  'runn',
                  '##ing',
                  ',',
                  'low',
                  'lowest',
              ]
              _UpperCAmelCase     =     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     =     {
                  'do_resize': True,
                  'size': 20,
                  'do_center_crop': True,
                  'crop_size': 18,
                  'do_normalize': True,
                  'image_mean': [0.48_145_466, 0.4_578_275, 0.40_821_073],
                  'image_std': [0.26_862_954, 0.26_130_258, 0.27_577_711],
              }
              _UpperCAmelCase     =     os.path.join(self.tmpdirname    ,  __SCREAMING_SNAKE_CASE     )
              with open(self.image_processor_file    ,  'w'    ,  encoding='utf-8'     ) as fp:
                     json.dump(__SCREAMING_SNAKE_CASE    ,  __SCREAMING_SNAKE_CASE     )






       def 							__A (   self    ,  **a__     ):
              return BertTokenizer.from_pretrained(self.tmpdirname    ,  **__SCREAMING_SNAKE_CASE     )






       def 							__A (   self    ,  **a__     ):
              return BertTokenizerFast.from_pretrained(self.tmpdirname    ,  **__SCREAMING_SNAKE_CASE     )






       def 							__A (   self    ,  **a__     ):
              return EfficientNetImageProcessor.from_pretrained(self.tmpdirname    ,  **__SCREAMING_SNAKE_CASE     )






       def 							__A (   self     ):
              shutil.rmtree(self.tmpdirname     )






       def 							__A (   self     ):
              _UpperCAmelCase     =     [np.random.randint(2_55    ,  size=(3, 30, 4_00)    ,  dtype=np.uinta     )]
              _UpperCAmelCase     =     [Image.fromarray(np.moveaxis(__SCREAMING_SNAKE_CASE    ,  0    ,  -1     )     ) for x in image_inputs]
              return image_inputs






       def 							__A (   self     ):
              _UpperCAmelCase     =     self.get_tokenizer()
              _UpperCAmelCase     =     self.get_rust_tokenizer()
              _UpperCAmelCase     =     self.get_image_processor()

              _UpperCAmelCase     =     AlignProcessor(tokenizer=__SCREAMING_SNAKE_CASE    ,  image_processor=__SCREAMING_SNAKE_CASE     )
              processor_slow.save_pretrained(self.tmpdirname     )
              _UpperCAmelCase     =     AlignProcessor.from_pretrained(self.tmpdirname    ,  use_fast=__SCREAMING_SNAKE_CASE     )

              _UpperCAmelCase     =     AlignProcessor(tokenizer=__SCREAMING_SNAKE_CASE    ,  image_processor=__SCREAMING_SNAKE_CASE     )
              processor_fast.save_pretrained(self.tmpdirname     )
              _UpperCAmelCase     =     AlignProcessor.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    ,  __SCREAMING_SNAKE_CASE     )
              self.assertIsInstance(processor_fast.tokenizer    ,  __SCREAMING_SNAKE_CASE     )

              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    ,  __SCREAMING_SNAKE_CASE     )
              self.assertIsInstance(processor_fast.image_processor    ,  __SCREAMING_SNAKE_CASE     )






       def 							__A (   self     ):
              _UpperCAmelCase     =     AlignProcessor(tokenizer=self.get_tokenizer()    ,  image_processor=self.get_image_processor()     )
              processor.save_pretrained(self.tmpdirname     )

              _UpperCAmelCase     =     self.get_tokenizer(bos_token='(BOS)'    ,  eos_token='(EOS)'     )
              _UpperCAmelCase     =     self.get_image_processor(do_normalize=__SCREAMING_SNAKE_CASE    ,  padding_value=1.0     )

              _UpperCAmelCase     =     AlignProcessor.from_pretrained(
                  self.tmpdirname    ,  bos_token='(BOS)'    ,  eos_token='(EOS)'    ,  do_normalize=__SCREAMING_SNAKE_CASE    ,  padding_value=1.0     )

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

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






       def 							__A (   self     ):
              _UpperCAmelCase     =     self.get_image_processor()
              _UpperCAmelCase     =     self.get_tokenizer()

              _UpperCAmelCase     =     AlignProcessor(tokenizer=__SCREAMING_SNAKE_CASE    ,  image_processor=__SCREAMING_SNAKE_CASE     )

              _UpperCAmelCase     =     self.prepare_image_inputs()

              _UpperCAmelCase     =     image_processor(__SCREAMING_SNAKE_CASE    ,  return_tensors='np'     )
              _UpperCAmelCase     =     processor(images=__SCREAMING_SNAKE_CASE    ,  return_tensors='np'     )

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






       def 							__A (   self     ):
              _UpperCAmelCase     =     self.get_image_processor()
              _UpperCAmelCase     =     self.get_tokenizer()

              _UpperCAmelCase     =     AlignProcessor(tokenizer=__SCREAMING_SNAKE_CASE    ,  image_processor=__SCREAMING_SNAKE_CASE     )

              _UpperCAmelCase     =     'lower newer'

              _UpperCAmelCase     =     processor(text=__SCREAMING_SNAKE_CASE     )

              _UpperCAmelCase     =     tokenizer(__SCREAMING_SNAKE_CASE    ,  padding='max_length'    ,  max_length=64     )

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






       def 							__A (   self     ):
              _UpperCAmelCase     =     self.get_image_processor()
              _UpperCAmelCase     =     self.get_tokenizer()

              _UpperCAmelCase     =     AlignProcessor(tokenizer=__SCREAMING_SNAKE_CASE    ,  image_processor=__SCREAMING_SNAKE_CASE     )

              _UpperCAmelCase     =     'lower newer'
              _UpperCAmelCase     =     self.prepare_image_inputs()

              _UpperCAmelCase     =     processor(text=__SCREAMING_SNAKE_CASE    ,  images=__SCREAMING_SNAKE_CASE     )

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






       def 							__A (   self     ):
              _UpperCAmelCase     =     self.get_image_processor()
              _UpperCAmelCase     =     self.get_tokenizer()

              _UpperCAmelCase     =     AlignProcessor(tokenizer=__SCREAMING_SNAKE_CASE    ,  image_processor=__SCREAMING_SNAKE_CASE     )

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

              _UpperCAmelCase     =     processor.batch_decode(__SCREAMING_SNAKE_CASE     )
              _UpperCAmelCase     =     tokenizer.batch_decode(__SCREAMING_SNAKE_CASE     )

              self.assertListEqual(__SCREAMING_SNAKE_CASE    ,  __SCREAMING_SNAKE_CASE     )






       def 							__A (   self     ):
              _UpperCAmelCase     =     self.get_image_processor()
              _UpperCAmelCase     =     self.get_tokenizer()

              _UpperCAmelCase     =     AlignProcessor(tokenizer=__SCREAMING_SNAKE_CASE    ,  image_processor=__SCREAMING_SNAKE_CASE     )

              _UpperCAmelCase     =     'lower newer'
              _UpperCAmelCase     =     self.prepare_image_inputs()

              _UpperCAmelCase     =     processor(text=__SCREAMING_SNAKE_CASE    ,  images=__SCREAMING_SNAKE_CASE     )

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













"""simple docstring"""






import sys

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

def       __lowerCamelCase    (       SCREAMING_SNAKE_CASE							)		->       int:






       """simple docstring"""




       _UpperCAmelCase     =     1
       for digit in s:
              product *= int(SCREAMING_SNAKE_CASE							)
       return product

def       __lowerCamelCase    (       SCREAMING_SNAKE_CASE = N							)		->       int:






       """simple docstring"""




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


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






