




'''simple docstring'''



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:
     UpperCAmelCase_							:	Any	     =		False

if is_vision_available():
     from PIL import Image

     from transformers import PixaStructImageProcessor





class      lowerCAmelCase (			unittest.TestCase):


       def __init__( self     ,	__SCREAMING_SNAKE_CASE     ,	__SCREAMING_SNAKE_CASE=7     ,	__SCREAMING_SNAKE_CASE=3     ,	__SCREAMING_SNAKE_CASE=18     ,	__SCREAMING_SNAKE_CASE=30     ,	__SCREAMING_SNAKE_CASE=400     ,	__SCREAMING_SNAKE_CASE=None     ,	__SCREAMING_SNAKE_CASE=True     ,	__SCREAMING_SNAKE_CASE=True     ,	__SCREAMING_SNAKE_CASE=None     ,	)   ->	int:



            '''simple docstring'''




            __snake_case            =	size if size is not None else {'''height''': 20, '''width''': 20}
            __snake_case            =	parent
            __snake_case            =	batch_size
            __snake_case            =	num_channels
            __snake_case            =	image_size
            __snake_case            =	min_resolution
            __snake_case            =	max_resolution
            __snake_case            =	size
            __snake_case            =	do_normalize
            __snake_case            =	do_convert_rgb
            __snake_case            =	[512, 1024, 2048, 4096]
            __snake_case            =	patch_size if patch_size is not None else {'''height''': 16, '''width''': 16}


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



            '''simple docstring'''




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




       def    lowerCAmelCase   ( self	)   ->	str:



            '''simple docstring'''




            __snake_case            =	'''https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/australia.jpg'''
            __snake_case            =	Image.open(requests.get(__SCREAMING_SNAKE_CASE     ,	stream=__SCREAMING_SNAKE_CASE	).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      lowerCAmelCase (			__lowerCAmelCase					, unittest.TestCase):
       __lowercase	:   str										=      PixaStructImageProcessor if is_vision_available() else None


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



            '''simple docstring'''




            __snake_case            =	PixaStructImageProcessingTester(self	)


       @property
       def    lowerCAmelCase   ( self	)   ->	Dict:



            '''simple docstring'''




            return self.image_processor_tester.prepare_image_processor_dict()


       def    lowerCAmelCase   ( self	)   ->	List[Any]:



            '''simple docstring'''




            __snake_case            =	self.image_processing_class(**self.image_processor_dict	)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE     ,	'''do_normalize'''	)	)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE     ,	'''do_convert_rgb'''	)	)


       def    lowerCAmelCase   ( self	)   ->	Optional[Any]:



            '''simple docstring'''




            __snake_case            =	self.image_processor_tester.prepare_dummy_image()

            __snake_case            =	self.image_processing_class(**self.image_processor_dict	)
            __snake_case            =	2048

            __snake_case            =	image_processor(__SCREAMING_SNAKE_CASE     ,	return_tensors='''pt'''     ,	max_patches=__SCREAMING_SNAKE_CASE	)
            self.assertTrue(torch.allclose(inputs.flattened_patches.mean()     ,	torch.tensor(0.0_606	)     ,	atol=1E-3     ,	rtol=1E-3	)	)


       def    lowerCAmelCase   ( self	)   ->	int:



            '''simple docstring'''




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

            # Test not batched input
            __snake_case            =	(
                (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
                 __snake_case            =	image_processor(
                     image_inputs[0]     ,	return_tensors='''pt'''     ,	max_patches=__SCREAMING_SNAKE_CASE	).flattened_patches
                 self.assertEqual(
                     encoded_images.shape     ,	(1, max_patch, expected_hidden_dim)     ,	)

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


       def    lowerCAmelCase   ( self	)   ->	Optional[int]:



            '''simple docstring'''




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

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

            __snake_case            =	True

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

                 __snake_case            =	'''Hello'''

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

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


       def    lowerCAmelCase   ( self	)   ->	int:



            '''simple docstring'''




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

            __snake_case            =	(
                (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
                 __snake_case            =	image_processor(
                     image_inputs[0]     ,	return_tensors='''pt'''     ,	max_patches=__SCREAMING_SNAKE_CASE	).flattened_patches
                 self.assertEqual(
                     encoded_images.shape     ,	(1, max_patch, expected_hidden_dim)     ,	)

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




       def    lowerCAmelCase   ( self	)   ->	Any:



            '''simple docstring'''




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

            # Test not batched input
            __snake_case            =	(
                (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
                 __snake_case            =	image_processor(
                     image_inputs[0]     ,	return_tensors='''pt'''     ,	max_patches=__SCREAMING_SNAKE_CASE	).flattened_patches
                 self.assertEqual(
                     encoded_images.shape     ,	(1, max_patch, expected_hidden_dim)     ,	)

                 # Test batched
                 __snake_case            =	image_processor(
                     __SCREAMING_SNAKE_CASE     ,	return_tensors='''pt'''     ,	max_patches=__SCREAMING_SNAKE_CASE	).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      lowerCAmelCase (			__lowerCAmelCase					, unittest.TestCase):
       __lowercase	:   int										=      PixaStructImageProcessor if is_vision_available() else None


       def    lowerCAmelCase   ( self	)   ->	Optional[Any]:



            '''simple docstring'''




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


       @property
       def    lowerCAmelCase   ( self	)   ->	Tuple:



            '''simple docstring'''




            return self.image_processor_tester.prepare_image_processor_dict()


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



            '''simple docstring'''




            __snake_case            =	self.image_processing_class(**self.image_processor_dict	)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE     ,	'''do_normalize'''	)	)
            self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE     ,	'''do_convert_rgb'''	)	)




       def    lowerCAmelCase   ( self	)   ->	Optional[int]:



            '''simple docstring'''




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

            # Test not batched input
            __snake_case            =	(
                (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
                 __snake_case            =	image_processor(
                     image_inputs[0]     ,	return_tensors='''pt'''     ,	max_patches=__SCREAMING_SNAKE_CASE	).flattened_patches
                 self.assertEqual(
                     encoded_images.shape     ,	(1, max_patch, expected_hidden_dim)     ,	)

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









def 	__a     (      A__			:  int = 1000       ):
    SCREAMING_SNAKE_CASE										=   3
    SCREAMING_SNAKE_CASE										=   0
    while a < n:
        if a % 3 == 0 or a % 5 == 0:
            result += a
        elif a % 15 == 0:
            result -= a
        a += 1
    return result


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