



"""simple docstring"""





import unittest

import numpy as np

from transformers.testing_utils import is_flaky, 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

if is_vision_available():
					from PIL import Image

					from transformers import DonutImageProcessor




class 			lowercase__			(      unittest.TestCase    ):
							'''simple docstring'''







							def __init__(  self	,       snake_case	,       snake_case=7	,       snake_case=3	,       snake_case=18	,       snake_case=30	,       snake_case=400	,       snake_case=True	,       snake_case=None	,       snake_case=True	,       snake_case=False	,       snake_case=True	,       snake_case=True	,       snake_case=[0.5, 0.5, 0.5]	,       snake_case=[0.5, 0.5, 0.5]	,       )			->							List[str]:
									_UpperCAmelCase							 =		parent
									_UpperCAmelCase							 =		batch_size
									_UpperCAmelCase							 =		num_channels
									_UpperCAmelCase							 =		image_size
									_UpperCAmelCase							 =		min_resolution
									_UpperCAmelCase							 =		max_resolution
									_UpperCAmelCase							 =		do_resize
									_UpperCAmelCase							 =		size if size is not None else {'height': 18, 'width': 20}
									_UpperCAmelCase							 =		do_thumbnail
									_UpperCAmelCase							 =		do_align_axis
									_UpperCAmelCase							 =		do_pad
									_UpperCAmelCase							 =		do_normalize
									_UpperCAmelCase							 =		image_mean
									_UpperCAmelCase							 =		image_std






							def        lowerCamelCase_   (  self						)			->							int:
									return {
									    "do_resize": self.do_resize,
									    "size": self.size,
									    "do_thumbnail": self.do_thumbnail,
									    "do_align_long_axis": self.do_align_axis,
									    "do_pad": self.do_pad,
									    "do_normalize": self.do_normalize,
									    "image_mean": self.image_mean,
									    "image_std": self.image_std,
									}







@require_torch
@require_vision
class 			lowercase__			(      A,					unittest.TestCase    ):
							'''simple docstring'''







							_UpperCAmelCase      				=					DonutImageProcessor if is_vision_available() else None






							def        lowerCamelCase_   (  self						)			->							List[Any]:
									_UpperCAmelCase							 =		DonutImageProcessingTester(self						)






							@property
							def        lowerCamelCase_   (  self						)			->							Any:
									return self.image_processor_tester.prepare_image_processor_dict()






							def        lowerCamelCase_   (  self						)			->							str:
									_UpperCAmelCase							 =		self.image_processing_class(**self.image_processor_dict						)
									self.assertTrue(hasattr(snake_case	,       'do_resize'						)						)
									self.assertTrue(hasattr(snake_case	,       'size'						)						)
									self.assertTrue(hasattr(snake_case	,       'do_thumbnail'						)						)
									self.assertTrue(hasattr(snake_case	,       'do_align_long_axis'						)						)
									self.assertTrue(hasattr(snake_case	,       'do_pad'						)						)
									self.assertTrue(hasattr(snake_case	,       'do_normalize'						)						)
									self.assertTrue(hasattr(snake_case	,       'image_mean'						)						)
									self.assertTrue(hasattr(snake_case	,       'image_std'						)						)






							def        lowerCamelCase_   (  self						)			->							str:
									_UpperCAmelCase							 =		self.image_processing_class.from_dict(self.image_processor_dict						)
									self.assertEqual(image_processor.size	,       {'height': 18, 'width': 20}						)

									_UpperCAmelCase							 =		self.image_processing_class.from_dict(self.image_processor_dict	,       size=42						)
									self.assertEqual(image_processor.size	,       {'height': 42, 'width': 42}						)

									# Previous config had dimensions in (width, height) order
									_UpperCAmelCase							 =		self.image_processing_class.from_dict(self.image_processor_dict	,       size=(42, 84)						)
									self.assertEqual(image_processor.size	,       {'height': 84, 'width': 42}						)






							def        lowerCamelCase_   (  self						)			->							Any:
									pass






							@is_flaky()
							def        lowerCamelCase_   (  self						)			->							Optional[Any]:
									# Initialize image_processing
									_UpperCAmelCase							 =		self.image_processing_class(**self.image_processor_dict						)
									# create random PIL images
									_UpperCAmelCase							 =		prepare_image_inputs(self.image_processor_tester	,       equal_resolution=snake_case						)
									for image in image_inputs:
											self.assertIsInstance(snake_case	,       Image.Image						)

									# Test not batched input
									_UpperCAmelCase							 =		image_processing(image_inputs[0]	,       return_tensors='pt'						).pixel_values
									self.assertEqual(
									    encoded_images.shape	,       (
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size['height'],
									        self.image_processor_tester.size['width'],
									    )	,       )

									# Test batched
									_UpperCAmelCase							 =		image_processing(snake_case	,       return_tensors='pt'						).pixel_values
									self.assertEqual(
									    encoded_images.shape	,       (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size['height'],
									        self.image_processor_tester.size['width'],
									    )	,       )






							@is_flaky()
							def        lowerCamelCase_   (  self						)			->							List[Any]:
									# Initialize image_processing
									_UpperCAmelCase							 =		self.image_processing_class(**self.image_processor_dict						)
									# create random numpy tensors
									_UpperCAmelCase							 =		prepare_image_inputs(self.image_processor_tester	,       equal_resolution=snake_case	,       numpify=snake_case						)
									for image in image_inputs:
											self.assertIsInstance(snake_case	,       np.ndarray						)

									# Test not batched input
									_UpperCAmelCase							 =		image_processing(image_inputs[0]	,       return_tensors='pt'						).pixel_values
									self.assertEqual(
									    encoded_images.shape	,       (
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size['height'],
									        self.image_processor_tester.size['width'],
									    )	,       )

									# Test batched
									_UpperCAmelCase							 =		image_processing(snake_case	,       return_tensors='pt'						).pixel_values
									self.assertEqual(
									    encoded_images.shape	,       (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size['height'],
									        self.image_processor_tester.size['width'],
									    )	,       )






							@is_flaky()
							def        lowerCamelCase_   (  self						)			->							Dict:
									# Initialize image_processing
									_UpperCAmelCase							 =		self.image_processing_class(**self.image_processor_dict						)
									# create random PyTorch tensors
									_UpperCAmelCase							 =		prepare_image_inputs(self.image_processor_tester	,       equal_resolution=snake_case	,       torchify=snake_case						)
									for image in image_inputs:
											self.assertIsInstance(snake_case	,       torch.Tensor						)

									# Test not batched input
									_UpperCAmelCase							 =		image_processing(image_inputs[0]	,       return_tensors='pt'						).pixel_values
									self.assertEqual(
									    encoded_images.shape	,       (
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size['height'],
									        self.image_processor_tester.size['width'],
									    )	,       )

									# Test batched
									_UpperCAmelCase							 =		image_processing(snake_case	,       return_tensors='pt'						).pixel_values
									self.assertEqual(
									    encoded_images.shape	,       (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size['height'],
									        self.image_processor_tester.size['width'],
									    )	,       )







"""simple docstring"""





from itertools import permutations




def 	UpperCAmelCase     (		A	:						tuple       ):

		'''simple docstring'''


		if num[3] % 2 != 0:
				return False

		if (num[2] + num[3] + num[4]) % 3 != 0:
				return False

		if num[5] % 5 != 0:
				return False

		_UpperCAmelCase							 =		[7, 11, 13, 17]
		for i, test in enumerate(A       ):
				if (num[i + 4] * 100 + num[i + 5] * 10 + num[i + 6]) % test != 0:
						return False
		return True




def 	UpperCAmelCase     (		A	:						int = 10       ):

		'''simple docstring'''


		return sum(
		    int(''.join(map(A     ,				A       )       )       )
		    for num in permutations(range(A       )       )
		    if is_substring_divisible(A       )       )


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


