
"""simple docstring"""

import unittest

import numpy as np
from datasets import load_dataset

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

if is_vision_available():
					from PIL import Image

					from transformers import BeitImageProcessor






class 	_lowercase       (    unittest.TestCase		):




	def __init__(			self		,			UpperCAmelCase_		,			UpperCAmelCase_=7		,			UpperCAmelCase_=3		,			UpperCAmelCase_=18		,			UpperCAmelCase_=30		,			UpperCAmelCase_=400		,			UpperCAmelCase_=True		,			UpperCAmelCase_=None		,			UpperCAmelCase_=True		,			UpperCAmelCase_=None		,			UpperCAmelCase_=True		,			UpperCAmelCase_=[0.5, 0.5, 0.5]		,			UpperCAmelCase_=[0.5, 0.5, 0.5]		,			UpperCAmelCase_=False		,			)		->							List[str]:
			lowerCamelCase					:      Tuple          =   size if size is not None else {'height': 20, 'width': 20}
			lowerCamelCase					:      List[str]          =   crop_size if crop_size is not None else {'height': 18, 'width': 18}
			lowerCamelCase					:      str          =   parent
			lowerCamelCase					:      Optional[Any]          =   batch_size
			lowerCamelCase					:      Optional[Any]          =   num_channels
			lowerCamelCase					:      str          =   image_size
			lowerCamelCase					:      Union[str, Any]          =   min_resolution
			lowerCamelCase					:      Tuple          =   max_resolution
			lowerCamelCase					:      Any          =   do_resize
			lowerCamelCase					:      Optional[int]          =   size
			lowerCamelCase					:      Union[str, Any]          =   do_center_crop
			lowerCamelCase					:      Tuple          =   crop_size
			lowerCamelCase					:      Union[str, Any]          =   do_normalize
			lowerCamelCase					:      Optional[Any]          =   image_mean
			lowerCamelCase					:      List[str]          =   image_std
			lowerCamelCase					:      Union[str, Any]          =   do_reduce_labels




	def       _UpperCamelCase   (			self )		->							List[Any]:
			return {
			    "do_resize": self.do_resize,
			    "size": self.size,
			    "do_center_crop": self.do_center_crop,
			    "crop_size": self.crop_size,
			    "do_normalize": self.do_normalize,
			    "image_mean": self.image_mean,
			    "image_std": self.image_std,
			    "do_reduce_labels": self.do_reduce_labels,
			}


def 		UpperCAmelCase (		):





		'''simple docstring'''


		lowerCamelCase					:      List[str]          =   load_dataset('hf-internal-testing/fixtures_ade20k',						split='test'      )

		lowerCamelCase					:      Optional[int]          =   Image.open(dataset[0]['file']      )
		lowerCamelCase					:      Any          =   Image.open(dataset[1]['file']      )

		return image, map
def 		UpperCAmelCase (		):





		'''simple docstring'''


		lowerCamelCase					:      List[str]          =   load_dataset('hf-internal-testing/fixtures_ade20k',						split='test'      )

		lowerCamelCase					:      List[str]          =   Image.open(ds[0]['file']      )
		lowerCamelCase					:      List[str]          =   Image.open(ds[1]['file']      )
		lowerCamelCase					:      Tuple          =   Image.open(ds[2]['file']      )
		lowerCamelCase					:      List[str]          =   Image.open(ds[3]['file']      )

		return [imagea, imagea], [mapa, mapa]






@require_torch
@require_vision
class 	_lowercase       (    __UpperCAmelCase    ,	unittest.TestCase		):
	lowercase_				=     BeitImageProcessor if is_vision_available() else None




	def       _UpperCamelCase   (			self )		->							Optional[int]:
			lowerCamelCase					:      int          =   BeitImageProcessingTester(self )




	@property
	def       _UpperCamelCase   (			self )		->							List[Any]:
			return self.image_processor_tester.prepare_image_processor_dict()




	def       _UpperCamelCase   (			self )		->							int:
			lowerCamelCase					:      List[str]          =   self.image_processing_class(**self.image_processor_dict )
			self.assertTrue(hasattr(UpperCAmelCase_		,			'do_resize' ) )
			self.assertTrue(hasattr(UpperCAmelCase_		,			'size' ) )
			self.assertTrue(hasattr(UpperCAmelCase_		,			'do_center_crop' ) )
			self.assertTrue(hasattr(UpperCAmelCase_		,			'center_crop' ) )
			self.assertTrue(hasattr(UpperCAmelCase_		,			'do_normalize' ) )
			self.assertTrue(hasattr(UpperCAmelCase_		,			'image_mean' ) )
			self.assertTrue(hasattr(UpperCAmelCase_		,			'image_std' ) )




	def       _UpperCamelCase   (			self )		->							List[str]:
			lowerCamelCase					:      str          =   self.image_processing_class.from_dict(self.image_processor_dict )
			self.assertEqual(image_processor.size		,			{'height': 20, 'width': 20} )
			self.assertEqual(image_processor.crop_size		,			{'height': 18, 'width': 18} )
			self.assertEqual(image_processor.do_reduce_labels		,			UpperCAmelCase_ )

			lowerCamelCase					:      Union[str, Any]          =   self.image_processing_class.from_dict(
			    self.image_processor_dict		,			size=42		,			crop_size=84		,			reduce_labels=UpperCAmelCase_ )
			self.assertEqual(image_processor.size		,			{'height': 42, 'width': 42} )
			self.assertEqual(image_processor.crop_size		,			{'height': 84, 'width': 84} )
			self.assertEqual(image_processor.do_reduce_labels		,			UpperCAmelCase_ )




	def       _UpperCamelCase   (			self )		->							Optional[int]:
			pass




	def       _UpperCamelCase   (			self )		->							Union[str, Any]:
			# Initialize image_processing
			lowerCamelCase					:      int          =   self.image_processing_class(**self.image_processor_dict )
			# create random PIL images
			lowerCamelCase					:      Dict          =   prepare_image_inputs(self.image_processor_tester		,			equal_resolution=UpperCAmelCase_ )
			for image in image_inputs:
					self.assertIsInstance(UpperCAmelCase_		,			Image.Image )

			# Test not batched input
			lowerCamelCase					:      List[Any]          =   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.crop_size['height'],
			        self.image_processor_tester.crop_size['width'],
			    )		,			)

			# Test batched
			lowerCamelCase					:      Any          =   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.crop_size['height'],
			        self.image_processor_tester.crop_size['width'],
			    )		,			)




	def       _UpperCamelCase   (			self )		->							Dict:
			# Initialize image_processing
			lowerCamelCase					:      Dict          =   self.image_processing_class(**self.image_processor_dict )
			# create random numpy tensors
			lowerCamelCase					:      Any          =   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
			lowerCamelCase					:      List[str]          =   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.crop_size['height'],
			        self.image_processor_tester.crop_size['width'],
			    )		,			)

			# Test batched
			lowerCamelCase					:      str          =   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.crop_size['height'],
			        self.image_processor_tester.crop_size['width'],
			    )		,			)




	def       _UpperCamelCase   (			self )		->							Tuple:
			# Initialize image_processing
			lowerCamelCase					:      List[str]          =   self.image_processing_class(**self.image_processor_dict )
			# create random PyTorch tensors
			lowerCamelCase					:      List[str]          =   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
			lowerCamelCase					:      int          =   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.crop_size['height'],
			        self.image_processor_tester.crop_size['width'],
			    )		,			)

			# Test batched
			lowerCamelCase					:      Dict          =   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.crop_size['height'],
			        self.image_processor_tester.crop_size['width'],
			    )		,			)




	def       _UpperCamelCase   (			self )		->							Tuple:
			# Initialize image_processing
			lowerCamelCase					:      Optional[int]          =   self.image_processing_class(**self.image_processor_dict )
			# create random PyTorch tensors
			lowerCamelCase					:      str          =   prepare_image_inputs(self.image_processor_tester		,			equal_resolution=UpperCAmelCase_		,			torchify=UpperCAmelCase_ )
			lowerCamelCase					:      Union[str, Any]          =   []
			for image in image_inputs:
					self.assertIsInstance(UpperCAmelCase_		,			torch.Tensor )
					maps.append(torch.zeros(image.shape[-2:] ).long() )

			# Test not batched input
			lowerCamelCase					:      Any          =   image_processing(image_inputs[0]		,			maps[0]		,			return_tensors='pt' )
			self.assertEqual(
			    encoding['pixel_values'].shape		,			(
			        1,
			        self.image_processor_tester.num_channels,
			        self.image_processor_tester.crop_size['height'],
			        self.image_processor_tester.crop_size['width'],
			    )		,			)
			self.assertEqual(
			    encoding['labels'].shape		,			(
			        1,
			        self.image_processor_tester.crop_size['height'],
			        self.image_processor_tester.crop_size['width'],
			    )		,			)
			self.assertEqual(encoding['labels'].dtype		,			torch.long )
			self.assertTrue(encoding['labels'].min().item() >= 0 )
			self.assertTrue(encoding['labels'].max().item() <= 255 )

			# Test batched
			lowerCamelCase					:      Tuple          =   image_processing(UpperCAmelCase_		,			UpperCAmelCase_		,			return_tensors='pt' )
			self.assertEqual(
			    encoding['pixel_values'].shape		,			(
			        self.image_processor_tester.batch_size,
			        self.image_processor_tester.num_channels,
			        self.image_processor_tester.crop_size['height'],
			        self.image_processor_tester.crop_size['width'],
			    )		,			)
			self.assertEqual(
			    encoding['labels'].shape		,			(
			        self.image_processor_tester.batch_size,
			        self.image_processor_tester.crop_size['height'],
			        self.image_processor_tester.crop_size['width'],
			    )		,			)
			self.assertEqual(encoding['labels'].dtype		,			torch.long )
			self.assertTrue(encoding['labels'].min().item() >= 0 )
			self.assertTrue(encoding['labels'].max().item() <= 255 )

			# Test not batched input (PIL images)
			lowerCamelCase     ,   lowerCamelCase					:      List[str]          =   prepare_semantic_single_inputs()

			lowerCamelCase					:      List[str]          =   image_processing(UpperCAmelCase_		,			UpperCAmelCase_		,			return_tensors='pt' )
			self.assertEqual(
			    encoding['pixel_values'].shape		,			(
			        1,
			        self.image_processor_tester.num_channels,
			        self.image_processor_tester.crop_size['height'],
			        self.image_processor_tester.crop_size['width'],
			    )		,			)
			self.assertEqual(
			    encoding['labels'].shape		,			(
			        1,
			        self.image_processor_tester.crop_size['height'],
			        self.image_processor_tester.crop_size['width'],
			    )		,			)
			self.assertEqual(encoding['labels'].dtype		,			torch.long )
			self.assertTrue(encoding['labels'].min().item() >= 0 )
			self.assertTrue(encoding['labels'].max().item() <= 255 )

			# Test batched input (PIL images)
			lowerCamelCase     ,   lowerCamelCase					:      Tuple          =   prepare_semantic_batch_inputs()

			lowerCamelCase					:      Optional[int]          =   image_processing(UpperCAmelCase_		,			UpperCAmelCase_		,			return_tensors='pt' )
			self.assertEqual(
			    encoding['pixel_values'].shape		,			(
			        2,
			        self.image_processor_tester.num_channels,
			        self.image_processor_tester.crop_size['height'],
			        self.image_processor_tester.crop_size['width'],
			    )		,			)
			self.assertEqual(
			    encoding['labels'].shape		,			(
			        2,
			        self.image_processor_tester.crop_size['height'],
			        self.image_processor_tester.crop_size['width'],
			    )		,			)
			self.assertEqual(encoding['labels'].dtype		,			torch.long )
			self.assertTrue(encoding['labels'].min().item() >= 0 )
			self.assertTrue(encoding['labels'].max().item() <= 255 )




	def       _UpperCamelCase   (			self )		->							Tuple:
			# Initialize image_processing
			lowerCamelCase					:      List[Any]          =   self.image_processing_class(**self.image_processor_dict )

			# ADE20k has 150 classes, and the background is included, so labels should be between 0 and 150
			lowerCamelCase     ,   lowerCamelCase					:      Optional[Any]          =   prepare_semantic_single_inputs()
			lowerCamelCase					:      int          =   image_processing(UpperCAmelCase_		,			UpperCAmelCase_		,			return_tensors='pt' )
			self.assertTrue(encoding['labels'].min().item() >= 0 )
			self.assertTrue(encoding['labels'].max().item() <= 150 )

			lowerCamelCase					:      Optional[Any]          =   True
			lowerCamelCase					:      Union[str, Any]          =   image_processing(UpperCAmelCase_		,			UpperCAmelCase_		,			return_tensors='pt' )
			self.assertTrue(encoding['labels'].min().item() >= 0 )
			self.assertTrue(encoding['labels'].max().item() <= 255 )








"""simple docstring"""

def 		UpperCAmelCase (		a_      ):





		'''simple docstring'''


		lowerCamelCase					:      List[Any]          =   1
		for i in range(1,						num + 1      ):
				fact *= i
		return fact
def 		UpperCAmelCase (		a_      ):





		'''simple docstring'''


		lowerCamelCase					:      Optional[Any]          =   0
		while number > 0:
				lowerCamelCase					:      str          =   number % 10
				sum_of_digits += last_digit
				lowerCamelCase					:      Tuple          =   number // 10  # Removing the last_digit from the given number
		return sum_of_digits
def 		UpperCAmelCase (		a_ = 100      ):





		'''simple docstring'''


		lowerCamelCase					:      Optional[Any]          =   factorial(a_      )
		lowerCamelCase					:      int          =   split_and_add(a_      )
		return result


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






