

'''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 					A__      (      unittest.TestCase			):



				def __init__(					self		,				UpperCamelCase__		,				UpperCamelCase__=7		,				UpperCamelCase__=3		,				UpperCamelCase__=18		,				UpperCamelCase__=30		,				UpperCamelCase__=400		,				UpperCamelCase__=True		,				UpperCamelCase__=None		,				UpperCamelCase__=True		,				UpperCamelCase__=False		,				UpperCamelCase__=True		,				UpperCamelCase__=True		,				UpperCamelCase__=[0.5, 0.5, 0.5]		,				UpperCamelCase__=[0.5, 0.5, 0.5]		,				)						->      List[str]:





											'''simple docstring'''
											A_						=      parent
											A_						=      batch_size
											A_						=      num_channels
											A_						=      image_size
											A_						=      min_resolution
											A_						=      max_resolution
											A_						=      do_resize
											A_						=      size if size is not None else {"""height""": 18, """width""": 20}
											A_						=      do_thumbnail
											A_						=      do_align_axis
											A_						=      do_pad
											A_						=      do_normalize
											A_						=      image_mean
											A_						=      image_std







				def 					snake_case_			(					self       )						->      Tuple:





											'''simple docstring'''
											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 					A__      (      _snake_case						,						unittest.TestCase			):
				lowercase						=		DonutImageProcessor if is_vision_available() else None



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





											'''simple docstring'''
											A_						=      DonutImageProcessingTester(self       )



				@property
				def 					snake_case_			(					self       )						->      List[str]:





											'''simple docstring'''
											return self.image_processor_tester.prepare_image_processor_dict()



				def 					snake_case_			(					self       )						->      int:





											'''simple docstring'''
											A_						=      self.image_processing_class(**self.image_processor_dict       )
											self.assertTrue(hasattr(UpperCamelCase__		,				"""do_resize"""       )       )
											self.assertTrue(hasattr(UpperCamelCase__		,				"""size"""       )       )
											self.assertTrue(hasattr(UpperCamelCase__		,				"""do_thumbnail"""       )       )
											self.assertTrue(hasattr(UpperCamelCase__		,				"""do_align_long_axis"""       )       )
											self.assertTrue(hasattr(UpperCamelCase__		,				"""do_pad"""       )       )
											self.assertTrue(hasattr(UpperCamelCase__		,				"""do_normalize"""       )       )
											self.assertTrue(hasattr(UpperCamelCase__		,				"""image_mean"""       )       )
											self.assertTrue(hasattr(UpperCamelCase__		,				"""image_std"""       )       )



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





											'''simple docstring'''
											A_						=      self.image_processing_class.from_dict(self.image_processor_dict       )
											self.assertEqual(image_processor.size		,				{"""height""": 18, """width""": 20}       )

											A_						=      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
											A_						=      self.image_processing_class.from_dict(self.image_processor_dict		,				size=(42, 84)       )
											self.assertEqual(image_processor.size		,				{"""height""": 84, """width""": 42}       )



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





											'''simple docstring'''
											pass



				@is_flaky()
				def 					snake_case_			(					self       )						->      Optional[Any]:





											'''simple docstring'''
											A_						=      self.image_processing_class(**self.image_processor_dict       )
											# create random PIL images
											A_						=      prepare_image_inputs(self.image_processor_tester		,				equal_resolution=UpperCamelCase__       )
											for image in image_inputs:
																		self.assertIsInstance(UpperCamelCase__		,				Image.Image       )

											# Test not batched input
											A_						=      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
											A_						=      image_processing(UpperCamelCase__		,				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 					snake_case_			(					self       )						->      int:





											'''simple docstring'''
											A_						=      self.image_processing_class(**self.image_processor_dict       )
											# create random numpy tensors
											A_						=      prepare_image_inputs(self.image_processor_tester		,				equal_resolution=UpperCamelCase__		,				numpify=UpperCamelCase__       )
											for image in image_inputs:
																		self.assertIsInstance(UpperCamelCase__		,				np.ndarray       )

											# Test not batched input
											A_						=      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
											A_						=      image_processing(UpperCamelCase__		,				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 					snake_case_			(					self       )						->      List[Any]:





											'''simple docstring'''
											A_						=      self.image_processing_class(**self.image_processor_dict       )
											# create random PyTorch tensors
											A_						=      prepare_image_inputs(self.image_processor_tester		,				equal_resolution=UpperCamelCase__		,				torchify=UpperCamelCase__       )
											for image in image_inputs:
																		self.assertIsInstance(UpperCamelCase__		,				torch.Tensor       )

											# Test not batched input
											A_						=      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
											A_						=      image_processing(UpperCamelCase__		,				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'''







def       UpperCAmelCase__    (      UpperCAmelCase__				)			->			bool:
       return str(UpperCAmelCase__				) == str(UpperCAmelCase__				)[::-1]
def       UpperCAmelCase__    (      UpperCAmelCase__				)			->			int:
       return int(UpperCAmelCase__				) + int(str(UpperCAmelCase__				)[::-1]				)
def       UpperCAmelCase__    (      UpperCAmelCase__ = 1_00_00				)			->			int:
       A_						=      []
       for num in range(1,       UpperCAmelCase__				):
              A_						=      0
              A_						=      num
              while iterations < 50:
                     A_						=      sum_reverse(UpperCAmelCase__				)
                     iterations += 1
                     if is_palindrome(UpperCAmelCase__				):
                            break
              else:
                     lychrel_nums.append(UpperCAmelCase__				)
       return len(UpperCAmelCase__				)


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