


import inspect
import unittest
from math import floor

from transformers import CvtConfig
from transformers.file_utils import cached_property, is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
	import torch

	from transformers import CvtForImageClassification, CvtModel
	from transformers.models.cvt.modeling_cvt import CVT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
	from PIL import Image

	from transformers import AutoImageProcessor


class 			lowerCamelCase_		(			UpperCAmelCase_   ):





				"""simple docstring"""







				def   lowerCAmelCase__		(						self     ):
								SCREAMING_SNAKE_CASE__     							=				self.config_class(**self.inputs_dict     )
								self.parent.assertTrue(hasattr(_lowercase       ,		"embed_dim"     )     )
								self.parent.assertTrue(hasattr(_lowercase       ,		"num_heads"     )     )


class 			lowerCamelCase_		:





				"""simple docstring"""







				def __init__(						self       ,		UpperCAmelCase__       ,		UpperCAmelCase__=13       ,		UpperCAmelCase__=64       ,		UpperCAmelCase__=3       ,		UpperCAmelCase__=[16, 48, 96]       ,		UpperCAmelCase__=[1, 3, 6]       ,		UpperCAmelCase__=[1, 2, 10]       ,		UpperCAmelCase__=[7, 3, 3]       ,		UpperCAmelCase__=[4, 2, 2]       ,		UpperCAmelCase__=[2, 1, 1]       ,		UpperCAmelCase__=[2, 2, 2]       ,		UpperCAmelCase__=[False, False, True]       ,		UpperCAmelCase__=[0.0, 0.0, 0.0]       ,		UpperCAmelCase__=0.02       ,		UpperCAmelCase__=1e-12       ,		UpperCAmelCase__=True       ,		UpperCAmelCase__=True       ,		UpperCAmelCase__=2       ,		):
								SCREAMING_SNAKE_CASE__     							=				parent
								SCREAMING_SNAKE_CASE__     							=				batch_size
								SCREAMING_SNAKE_CASE__     							=				image_size
								SCREAMING_SNAKE_CASE__     							=				patch_sizes
								SCREAMING_SNAKE_CASE__     							=				patch_stride
								SCREAMING_SNAKE_CASE__     							=				patch_padding
								SCREAMING_SNAKE_CASE__     							=				is_training
								SCREAMING_SNAKE_CASE__     							=				use_labels
								SCREAMING_SNAKE_CASE__     							=				num_labels
								SCREAMING_SNAKE_CASE__     							=				num_channels
								SCREAMING_SNAKE_CASE__     							=				embed_dim
								SCREAMING_SNAKE_CASE__     							=				num_heads
								SCREAMING_SNAKE_CASE__     							=				stride_kv
								SCREAMING_SNAKE_CASE__     							=				depth
								SCREAMING_SNAKE_CASE__     							=				cls_token
								SCREAMING_SNAKE_CASE__     							=				attention_drop_rate
								SCREAMING_SNAKE_CASE__     							=				initializer_range
								SCREAMING_SNAKE_CASE__     							=				layer_norm_eps



				def   lowerCAmelCase__		(						self     ):
								SCREAMING_SNAKE_CASE__     							=				floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]     )

								SCREAMING_SNAKE_CASE__     							=				None
								if self.use_labels:
												SCREAMING_SNAKE_CASE__     							=				ids_tensor([self.batch_size]       ,		self.num_labels     )

								SCREAMING_SNAKE_CASE__     							=				self.get_config()
								return config, pixel_values, labels



				def   lowerCAmelCase__		(						self     ):
								return CvtConfig(
								    image_size=self.image_size       ,		num_labels=self.num_labels       ,		num_channels=self.num_channels       ,		embed_dim=self.embed_dim       ,		num_heads=self.num_heads       ,		patch_sizes=self.patch_sizes       ,		patch_padding=self.patch_padding       ,		patch_stride=self.patch_stride       ,		stride_kv=self.stride_kv       ,		depth=self.depth       ,		cls_token=self.cls_token       ,		attention_drop_rate=self.attention_drop_rate       ,		initializer_range=self.initializer_range       ,		)



				def   lowerCAmelCase__		(						self       ,		UpperCAmelCase__       ,		UpperCAmelCase__       ,		UpperCAmelCase__     ):
								SCREAMING_SNAKE_CASE__     							=				CvtModel(config=_lowercase     )
								model.to(_lowercase     )
								model.eval()
								SCREAMING_SNAKE_CASE__     							=				model(_lowercase     )
								SCREAMING_SNAKE_CASE__     							=				(self.image_size, self.image_size)
								SCREAMING_SNAKE_CASE__     							=				image_size[0], image_size[1]
								for i in range(len(self.depth     )     ):
												SCREAMING_SNAKE_CASE__     							=				floor(((height + 2 * self.patch_padding[i] - self.patch_sizes[i]) / self.patch_stride[i]) + 1     )
												SCREAMING_SNAKE_CASE__     							=				floor(((width + 2 * self.patch_padding[i] - self.patch_sizes[i]) / self.patch_stride[i]) + 1     )
								self.parent.assertEqual(result.last_hidden_state.shape       ,		(self.batch_size, self.embed_dim[-1], height, width)     )



				def   lowerCAmelCase__		(						self       ,		UpperCAmelCase__       ,		UpperCAmelCase__       ,		UpperCAmelCase__     ):
								SCREAMING_SNAKE_CASE__     							=				self.num_labels
								SCREAMING_SNAKE_CASE__     							=				CvtForImageClassification(_lowercase     )
								model.to(_lowercase     )
								model.eval()
								SCREAMING_SNAKE_CASE__     							=				model(_lowercase       ,		labels=_lowercase     )
								self.parent.assertEqual(result.logits.shape       ,		(self.batch_size, self.num_labels)     )






				def   lowerCAmelCase__		(						self     ):
								SCREAMING_SNAKE_CASE__     							=				self.prepare_config_and_inputs()
								SCREAMING_SNAKE_CASE__     							=				config_and_inputs
								SCREAMING_SNAKE_CASE__     							=				{'pixel_values': pixel_values}
								return config, inputs_dict


@require_torch
class 			lowerCamelCase_		(			UpperCAmelCase_       ,  UpperCAmelCase_       ,  unittest.TestCase   ):





				"""simple docstring"""







				_lowerCAmelCase      :      Optional[int]      							=					(CvtModel, CvtForImageClassification) if is_torch_available() else ()
				_lowerCAmelCase      :      List[str]      							=					(
				    {'feature-extraction': CvtModel, 'image-classification': CvtForImageClassification}
				    if is_torch_available()
				    else {}
				)

				_lowerCAmelCase      :      Union[str, Any]      							=					False
				_lowerCAmelCase      :      Any      							=					False
				_lowerCAmelCase      :      Any      							=					False
				_lowerCAmelCase      :      Union[str, Any]      							=					False
				_lowerCAmelCase      :      Dict      							=					False



				def   lowerCAmelCase__		(						self     ):
								SCREAMING_SNAKE_CASE__     							=				CvtModelTester(self     )
								SCREAMING_SNAKE_CASE__     							=				ConfigTester(self       ,		config_class=_lowercase       ,		has_text_modality=_lowercase       ,		hidden_size=37     )



				def   lowerCAmelCase__		(						self     ):
								self.create_and_test_config_common_properties()
								self.config_tester.create_and_test_config_to_json_string()
								self.config_tester.create_and_test_config_to_json_file()
								self.config_tester.create_and_test_config_from_and_save_pretrained()
								self.config_tester.create_and_test_config_with_num_labels()
								self.config_tester.check_config_can_be_init_without_params()
								self.config_tester.check_config_arguments_init()



				def   lowerCAmelCase__		(						self     ):
								return



				@unittest.skip(reason="Cvt does not output attentions"     )
				def   lowerCAmelCase__		(						self     ):
								pass



				@unittest.skip(reason="Cvt does not use inputs_embeds"     )
				def   lowerCAmelCase__		(						self     ):
								pass



				@unittest.skip(reason="Cvt does not support input and output embeddings"     )
				def   lowerCAmelCase__		(						self     ):
								pass



				def   lowerCAmelCase__		(						self     ):
								SCREAMING_SNAKE_CASE__     							=				self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
												SCREAMING_SNAKE_CASE__     							=				model_class(_lowercase     )
												SCREAMING_SNAKE_CASE__     							=				inspect.signature(model.forward     )
												# signature.parameters is an OrderedDict => so arg_names order is deterministic
												SCREAMING_SNAKE_CASE__     							=				[*signature.parameters.keys()]

												SCREAMING_SNAKE_CASE__     							=				['pixel_values']
												self.assertListEqual(arg_names[:1]       ,		_lowercase     )



				def   lowerCAmelCase__		(						self     ):
								SCREAMING_SNAKE_CASE__     							=				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*_lowercase     )



				def   lowerCAmelCase__		(						self     ):
								def check_hidden_states_output(UpperCAmelCase__       ,		UpperCAmelCase__       ,		UpperCAmelCase__     ):
												SCREAMING_SNAKE_CASE__     							=				model_class(_lowercase     )
												model.to(_lowercase     )
												model.eval()

												with torch.no_grad():
																SCREAMING_SNAKE_CASE__     							=				model(**self._prepare_for_class(_lowercase       ,		_lowercase     )     )

												SCREAMING_SNAKE_CASE__     							=				outputs.hidden_states

												SCREAMING_SNAKE_CASE__     							=				len(self.model_tester.depth     )
												self.assertEqual(len(_lowercase     )       ,		_lowercase     )

												# verify the first hidden states (first block)
												self.assertListEqual(
												    list(hidden_states[0].shape[-3:]     )       ,		[
												        self.model_tester.embed_dim[0],
												        self.model_tester.image_size // 4,
												        self.model_tester.image_size // 4,
												    ]       ,		)

								SCREAMING_SNAKE_CASE__     							=				self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
												SCREAMING_SNAKE_CASE__     							=				True
												check_hidden_states_output(_lowercase       ,		_lowercase       ,		_lowercase     )

												# check that output_hidden_states also work using config
												del inputs_dict["output_hidden_states"]
												SCREAMING_SNAKE_CASE__     							=				True

												check_hidden_states_output(_lowercase       ,		_lowercase       ,		_lowercase     )



				def   lowerCAmelCase__		(						self     ):
								SCREAMING_SNAKE_CASE__     							=				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_image_classification(*_lowercase     )



				@unittest.skip("Will be fixed soon by reducing the size of the model used for common tests."     )
				def   lowerCAmelCase__		(						self     ):
								pass






				@slow
				def   lowerCAmelCase__		(						self     ):
								for model_name in CVT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
												SCREAMING_SNAKE_CASE__     							=				CvtModel.from_pretrained(_lowercase     )
												self.assertIsNotNone(_lowercase     )


def __lowercase     (      ):
				SCREAMING_SNAKE_CASE__     							=				Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"  )
				return image


@require_torch
@require_vision
class 			lowerCamelCase_		(			unittest.TestCase   ):





				"""simple docstring"""







				@cached_property
				def   lowerCAmelCase__		(						self     ):
								return AutoImageProcessor.from_pretrained(CVT_PRETRAINED_MODEL_ARCHIVE_LIST[0]     )






				@slow
				def   lowerCAmelCase__		(						self     ):
								SCREAMING_SNAKE_CASE__     							=				CvtForImageClassification.from_pretrained(CVT_PRETRAINED_MODEL_ARCHIVE_LIST[0]     ).to(_lowercase     )

								SCREAMING_SNAKE_CASE__     							=				self.default_image_processor
								SCREAMING_SNAKE_CASE__     							=				prepare_img()
								SCREAMING_SNAKE_CASE__     							=				image_processor(images=_lowercase       ,		return_tensors="pt"     ).to(_lowercase     )

								# forward pass
								with torch.no_grad():
												SCREAMING_SNAKE_CASE__     							=				model(**_lowercase     )

								# verify the logits
								SCREAMING_SNAKE_CASE__     							=				torch.Size((1, 1000)     )
								self.assertEqual(outputs.logits.shape       ,		_lowercase     )

								SCREAMING_SNAKE_CASE__     							=				torch.tensor([0.9_285, 0.9_015, -0.3_150]     ).to(_lowercase     )

								self.assertTrue(torch.allclose(outputs.logits[0, :3]       ,		_lowercase       ,		atol=1e-4     )     )




"""simple docstring"""






from math import factorial


def __lowercase     (      lowerCamelCase_  :      int = 100  ):
				return sum(int(lowerCamelCase_  ) for x in str(factorial(lowerCamelCase_  )  )  )


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