





import unittest

import numpy as np
import requests

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
      import torch

      from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_11
else:
      lowercase_          =		False

if is_vision_available():
      from PIL import Image

      from transformers import PixaStructImageProcessor
class     SCREAMING_SNAKE_CASE       (unittest.TestCase				):


   def __init__(   self      :    str      ,					a      :    Tuple      ,					a      :    Tuple=7      ,					a      :    Tuple=3      ,					a      :    Any=18      ,					a      :    str=30      ,					a      :    Dict=400      ,					a      :    List[Any]=None      ,					a      :    Optional[Any]=True      ,					a      :    Optional[int]=True      ,					a      :    str=None      ,					)->       str:





     """simple docstring"""







     lowercase__           =  size if size is not None else {'height': 20, 'width': 20}
     lowercase__           =  parent
     lowercase__           =  batch_size
     lowercase__           =  num_channels
     lowercase__           =  image_size
     lowercase__           =  min_resolution
     lowercase__           =  max_resolution
     lowercase__           =  size
     lowercase__           =  do_normalize
     lowercase__           =  do_convert_rgb
     lowercase__           =  [512, 1_024, 2_048, 4_096]
     lowercase__           =  patch_size if patch_size is not None else {'height': 16, 'width': 16}


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Optional[Any]	)->       List[str]:





     """simple docstring"""







     return {"do_normalize": self.do_normalize, "do_convert_rgb": self.do_convert_rgb}


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Dict	)->       List[Any]:





     """simple docstring"""







     lowercase__           =  'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/australia.jpg'
     lowercase__           =  Image.open(requests.get(a__      ,					stream=a__	).raw	).convert('RGB'	)
     return raw_image






@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11      ,     reason='`Pix2StructImageProcessor` requires `torch>=1.11.0`.'      ,     )
@require_torch
@require_vision
class     SCREAMING_SNAKE_CASE       (lowerCAmelCase__      ,     unittest.TestCase				):
   _UpperCamelCase   :		Tuple			 =	PixaStructImageProcessor if is_vision_available() else None


   def 	SCREAMING_SNAKE_CASE_							(   self      :    int	)->       Any:





     """simple docstring"""







     lowercase__           =  PixaStructImageProcessingTester(self	)


   @property
   def 	SCREAMING_SNAKE_CASE_							(   self      :    str	)->       str:





     """simple docstring"""







     return self.image_processor_tester.prepare_image_processor_dict()


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Any	)->       List[str]:





     """simple docstring"""







     lowercase__           =  self.image_processing_class(**self.image_processor_dict	)
     self.assertTrue(hasattr(a__      ,					'do_normalize'	)	)
     self.assertTrue(hasattr(a__      ,					'do_convert_rgb'	)	)


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Dict	)->       Any:





     """simple docstring"""







     lowercase__           =  self.image_processor_tester.prepare_dummy_image()

     lowercase__           =  self.image_processing_class(**self.image_processor_dict	)
     lowercase__           =  2_048

     lowercase__           =  image_processor(a__      ,					return_tensors='pt'      ,					max_patches=a__	)
     self.assertTrue(torch.allclose(inputs.flattened_patches.mean()      ,					torch.tensor(0.0606	)      ,					atol=1E-3      ,					rtol=1E-3	)	)


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Tuple	)->       int:





     """simple docstring"""







     lowercase__           =  self.image_processing_class(**self.image_processor_dict	)
     # create random PIL images
     lowercase__           =  prepare_image_inputs(self.image_processor_tester      ,					equal_resolution=a__	)
     for image in image_inputs:
       self.assertIsInstance(a__      ,					Image.Image	)

     # Test not batched input
     lowercase__           =  (
         (self.image_processor_tester.patch_size['height'] * self.image_processor_tester.patch_size['width'])
         * self.image_processor_tester.num_channels
     ) + 2

     for max_patch in self.image_processor_tester.max_patches:
       # Test not batched input
       lowercase__           =  image_processor(
           image_inputs[0]      ,					return_tensors='pt'      ,					max_patches=a__	).flattened_patches
       self.assertEqual(
           encoded_images.shape      ,					(1, max_patch, expected_hidden_dim)      ,					)

       # Test batched
       lowercase__           =  image_processor(
           a__      ,					return_tensors='pt'      ,					max_patches=a__	).flattened_patches
       self.assertEqual(
           encoded_images.shape      ,					(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)      ,					)


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Dict	)->       List[str]:





     """simple docstring"""







     lowercase__           =  self.image_processing_class(**self.image_processor_dict	)
     # create random PIL images
     lowercase__           =  prepare_image_inputs(self.image_processor_tester      ,					equal_resolution=a__	)
     for image in image_inputs:
       self.assertIsInstance(a__      ,					Image.Image	)

     # Test not batched input
     lowercase__           =  (
         (self.image_processor_tester.patch_size['height'] * self.image_processor_tester.patch_size['width'])
         * self.image_processor_tester.num_channels
     ) + 2

     lowercase__           =  True

     for max_patch in self.image_processor_tester.max_patches:
       # Test not batched input
       with self.assertRaises(a__	):
         lowercase__           =  image_processor(
             image_inputs[0]      ,					return_tensors='pt'      ,					max_patches=a__	).flattened_patches

       lowercase__           =  'Hello'

       lowercase__           =  image_processor(
           image_inputs[0]      ,					return_tensors='pt'      ,					max_patches=a__      ,					header_text=a__	).flattened_patches
       self.assertEqual(
           encoded_images.shape      ,					(1, max_patch, expected_hidden_dim)      ,					)

       # Test batched
       lowercase__           =  image_processor(
           a__      ,					return_tensors='pt'      ,					max_patches=a__      ,					header_text=a__	).flattened_patches
       self.assertEqual(
           encoded_images.shape      ,					(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)      ,					)


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Optional[int]	)->       str:





     """simple docstring"""







     lowercase__           =  self.image_processing_class(**self.image_processor_dict	)
     # create random numpy tensors
     lowercase__           =  prepare_image_inputs(self.image_processor_tester      ,					equal_resolution=a__      ,					numpify=a__	)
     for image in image_inputs:
       self.assertIsInstance(a__      ,					np.ndarray	)

     lowercase__           =  (
         (self.image_processor_tester.patch_size['height'] * self.image_processor_tester.patch_size['width'])
         * self.image_processor_tester.num_channels
     ) + 2

     for max_patch in self.image_processor_tester.max_patches:
       # Test not batched input
       lowercase__           =  image_processor(
           image_inputs[0]      ,					return_tensors='pt'      ,					max_patches=a__	).flattened_patches
       self.assertEqual(
           encoded_images.shape      ,					(1, max_patch, expected_hidden_dim)      ,					)

       # Test batched
       lowercase__           =  image_processor(
           a__      ,					return_tensors='pt'      ,					max_patches=a__	).flattened_patches
       self.assertEqual(
           encoded_images.shape      ,					(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)      ,					)


   def 	SCREAMING_SNAKE_CASE_							(   self      :    str	)->       List[str]:





     """simple docstring"""







     lowercase__           =  self.image_processing_class(**self.image_processor_dict	)
     # create random PyTorch tensors
     lowercase__           =  prepare_image_inputs(self.image_processor_tester      ,					equal_resolution=a__      ,					torchify=a__	)
     for image in image_inputs:
       self.assertIsInstance(a__      ,					torch.Tensor	)

     # Test not batched input
     lowercase__           =  (
         (self.image_processor_tester.patch_size['height'] * self.image_processor_tester.patch_size['width'])
         * self.image_processor_tester.num_channels
     ) + 2

     for max_patch in self.image_processor_tester.max_patches:
       # Test not batched input
       lowercase__           =  image_processor(
           image_inputs[0]      ,					return_tensors='pt'      ,					max_patches=a__	).flattened_patches
       self.assertEqual(
           encoded_images.shape      ,					(1, max_patch, expected_hidden_dim)      ,					)

       # Test batched
       lowercase__           =  image_processor(
           a__      ,					return_tensors='pt'      ,					max_patches=a__	).flattened_patches
       self.assertEqual(
           encoded_images.shape      ,					(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)      ,					)






@unittest.skipIf(
    not is_torch_greater_or_equal_than_1_11      ,     reason='`Pix2StructImageProcessor` requires `torch>=1.11.0`.'      ,     )
@require_torch
@require_vision
class     SCREAMING_SNAKE_CASE       (lowerCAmelCase__      ,     unittest.TestCase				):
   _UpperCamelCase   :		str			 =	PixaStructImageProcessor if is_vision_available() else None


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Union[str, Any]	)->       Union[str, Any]:





     """simple docstring"""







     lowercase__           =  PixaStructImageProcessingTester(self      ,					num_channels=4	)
     lowercase__           =  3


   @property
   def 	SCREAMING_SNAKE_CASE_							(   self      :    str	)->       Any:





     """simple docstring"""







     return self.image_processor_tester.prepare_image_processor_dict()


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Optional[int]	)->       Union[str, Any]:





     """simple docstring"""







     lowercase__           =  self.image_processing_class(**self.image_processor_dict	)
     self.assertTrue(hasattr(a__      ,					'do_normalize'	)	)
     self.assertTrue(hasattr(a__      ,					'do_convert_rgb'	)	)


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Any	)->       Optional[int]:





     """simple docstring"""







     lowercase__           =  self.image_processing_class(**self.image_processor_dict	)
     # create random PIL images
     lowercase__           =  prepare_image_inputs(self.image_processor_tester      ,					equal_resolution=a__	)
     for image in image_inputs:
       self.assertIsInstance(a__      ,					Image.Image	)

     # Test not batched input
     lowercase__           =  (
         (self.image_processor_tester.patch_size['height'] * self.image_processor_tester.patch_size['width'])
         * (self.image_processor_tester.num_channels - 1)
     ) + 2

     for max_patch in self.image_processor_tester.max_patches:
       # Test not batched input
       lowercase__           =  image_processor(
           image_inputs[0]      ,					return_tensors='pt'      ,					max_patches=a__	).flattened_patches
       self.assertEqual(
           encoded_images.shape      ,					(1, max_patch, expected_hidden_dim)      ,					)

       # Test batched
       lowercase__           =  image_processor(
           a__      ,					return_tensors='pt'      ,					max_patches=a__	).flattened_patches
       self.assertEqual(
           encoded_images.shape      ,					(self.image_processor_tester.batch_size, max_patch, expected_hidden_dim)      ,					)









import sys

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




def       __UpperCamelCase  (_SCREAMING_SNAKE_CASE = N		)    ->       int:
  lowercase__           =  -sys.maxsize - 1
  for i in range(len(_SCREAMING_SNAKE_CASE		) - 12		):
    lowercase__           =  1
    for j in range(13		):
      product *= int(n[i + j]		)
    if product > largest_product:
      lowercase__           =  product
  return largest_product


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


