






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  :							List[Any]			  =    False

if is_vision_available():
							from PIL import Image

							from transformers import PixaStructImageProcessor




class 		UpperCAmelCase_						(	unittest.TestCase					):


						'''simple docstring'''




						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		,				) ->				str:
								snake_case_				:							str						 =       size if size is not None else {"height": 20, "width": 20}
								snake_case_				:							Dict						 =       parent
								snake_case_				:							List[str]						 =       batch_size
								snake_case_				:							Any						 =       num_channels
								snake_case_				:							str						 =       image_size
								snake_case_				:							Optional[Any]						 =       min_resolution
								snake_case_				:							List[str]						 =       max_resolution
								snake_case_				:							Union[str, Any]						 =       size
								snake_case_				:							Any						 =       do_normalize
								snake_case_				:							Any						 =       do_convert_rgb
								snake_case_				:							List[Any]						 =       [512, 1024, 2048, 4096]
								snake_case_				:							Tuple						 =       patch_size if patch_size is not None else {"height": 16, "width": 16}






						def       _lowerCAmelCase       (	self				) ->				Any:
								return {"do_normalize": self.do_normalize, "do_convert_rgb": self.do_convert_rgb}






						def       _lowerCAmelCase       (	self				) ->				Optional[int]:
								snake_case_				:							List[Any]						 =       "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/australia.jpg"
								snake_case_				:							List[str]						 =       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 		UpperCAmelCase_						(	SCREAMING_SNAKE_CASE__					,  unittest.TestCase					):


						'''simple docstring'''




						A     :   List[Any]						=					PixaStructImageProcessor if is_vision_available() else None






						def       _lowerCAmelCase       (	self				) ->				Optional[int]:
								snake_case_				:							Optional[int]						 =       PixaStructImageProcessingTester(self				)






						@property
						def       _lowerCAmelCase       (	self				) ->				int:
								return self.image_processor_tester.prepare_image_processor_dict()






						def       _lowerCAmelCase       (	self				) ->				Tuple:
								snake_case_				:							Any						 =       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				) ->				List[str]:
								snake_case_				:							List[str]						 =       self.image_processor_tester.prepare_dummy_image()

								snake_case_				:							Optional[int]						 =       self.image_processing_class(**self.image_processor_dict				)
								snake_case_				:							List[str]						 =       2048

								snake_case_				:							Union[str, Any]						 =       image_processor(_SCREAMING_SNAKE_CASE		,				return_tensors="pt"		,				max_patches=_SCREAMING_SNAKE_CASE				)
								self.assertTrue(torch.allclose(inputs.flattened_patches.mean()		,				torch.tensor(0.0606				)		,				atol=1e-3		,				rtol=1e-3				)				)






						def       _lowerCAmelCase       (	self				) ->				List[str]:
								# Initialize image_processor
								snake_case_				:							Union[str, Any]						 =       self.image_processing_class(**self.image_processor_dict				)
								# create random PIL images
								snake_case_				:							Dict						 =       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_				:							Union[str, Any]						 =       (
								    (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_				:							Optional[Any]						 =       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_				:							Any						 =       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				) ->				List[Any]:
								# Initialize image_processor
								snake_case_				:							Dict						 =       self.image_processing_class(**self.image_processor_dict				)
								# create random PIL images
								snake_case_				:							Optional[Any]						 =       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_				:							str						 =       (
								    (self.image_processor_tester.patch_size["height"] * self.image_processor_tester.patch_size["width"])
								    * self.image_processor_tester.num_channels
								) + 2

								snake_case_				:							int						 =       True

								for max_patch in self.image_processor_tester.max_patches:
										# Test not batched input
										with self.assertRaises(_SCREAMING_SNAKE_CASE				):
												snake_case_				:							List[Any]						 =       image_processor(
												    image_inputs[0]		,				return_tensors="pt"		,				max_patches=_SCREAMING_SNAKE_CASE				).flattened_patches

										snake_case_				:							Any						 =       "Hello"

										snake_case_				:							Union[str, Any]						 =       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_				:							List[Any]						 =       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				) ->				Dict:
								# Initialize image_processor
								snake_case_				:							str						 =       self.image_processing_class(**self.image_processor_dict				)
								# create random numpy tensors
								snake_case_				:							int						 =       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_				:							Any						 =       (
								    (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_				:							str						 =       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_				:							Union[str, Any]						 =       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				) ->				List[Any]:
								# Initialize image_processor
								snake_case_				:							int						 =       self.image_processing_class(**self.image_processor_dict				)
								# create random PyTorch tensors
								snake_case_				:							str						 =       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_				:							List[Any]						 =       (
								    (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_				:							Any						 =       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_				:							str						 =       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 		UpperCAmelCase_						(	SCREAMING_SNAKE_CASE__					,  unittest.TestCase					):


						'''simple docstring'''




						A     :   int						=					PixaStructImageProcessor if is_vision_available() else None






						def       _lowerCAmelCase       (	self				) ->				int:
								snake_case_				:							List[Any]						 =       PixaStructImageProcessingTester(self		,				num_channels=4				)
								snake_case_				:							Optional[Any]						 =       3






						@property
						def       _lowerCAmelCase       (	self				) ->				Tuple:
								return self.image_processor_tester.prepare_image_processor_dict()






						def       _lowerCAmelCase       (	self				) ->				Tuple:
								snake_case_				:							Tuple						 =       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				) ->				str:
								# Initialize image_processor
								snake_case_				:							str						 =       self.image_processing_class(**self.image_processor_dict				)
								# create random PIL images
								snake_case_				:							Optional[int]						 =       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_				:							Tuple						 =       (
								    (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_				:							Optional[Any]						 =       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_				:							int						 =       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__	(    _a       :			int    ):
		snake_case_				:							str						 =       1
		for i in range(1  ,      num + 1    ):
				fact *= i
		return fact

def      lowerCAmelCase__	(    _a       :			int    ):
		snake_case_				:							List[str]						 =       0
		while number > 0:
				snake_case_				:							Dict						 =       number % 10
				sum_of_digits += last_digit
				snake_case_				:							List[Any]						 =       number // 10  # Removing the last_digit from the given number
		return sum_of_digits

def      lowerCAmelCase__	(    _a       :			int = 1_00    ):
		snake_case_				:							Optional[Any]						 =       factorial(_a    )
		snake_case_				:							Optional[int]						 =       split_and_add(_a    )
		return result


if __name__ == "__main__":
							print(solution(int(input('''Enter the Number: ''').strip())))
