from __future__ import annotations

import inspect
import unittest
from math import floor

import numpy as np

from transformers import CvtConfig
from transformers.testing_utils import require_tf, require_vision, slow
from transformers.utils import cached_property, is_tf_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
	import tensorflow as tf

	from transformers import TFCvtForImageClassification, TFCvtModel
	from transformers.models.cvt.modeling_tf_cvt import TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
	from PIL import Image

	from transformers import AutoImageProcessor


class 						a__							(       _UpperCAmelCase		):



			def __SCREAMING_SNAKE_CASE							(						self   )			->   Optional[int]:
								__a		 =       self.config_class(**self.inputs_dict   )
								self.parent.assertTrue(hasattr(SCREAMING_SNAKE_CASE_				,						'embed_dim'   )   )
								self.parent.assertTrue(hasattr(SCREAMING_SNAKE_CASE_				,						'num_heads'   )   )






class 						a__							:



			def __init__(						self				,						UpperCAmelCase				,						UpperCAmelCase=1_3				,						UpperCAmelCase=6_4				,						UpperCAmelCase=3				,						UpperCAmelCase=[1_6, 4_8, 9_6]				,						UpperCAmelCase=[1, 3, 6]				,						UpperCAmelCase=[1, 2, 1_0]				,						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				,						)			->   List[Any]:
								__a		 =       parent
								__a		 =       batch_size
								__a		 =       image_size
								__a		 =       patch_sizes
								__a		 =       patch_stride
								__a		 =       patch_padding
								__a		 =       is_training
								__a		 =       use_labels
								__a		 =       num_labels
								__a		 =       num_channels
								__a		 =       embed_dim
								__a		 =       num_heads
								__a		 =       stride_kv
								__a		 =       depth
								__a		 =       cls_token
								__a		 =       attention_drop_rate
								__a		 =       initializer_range
								__a		 =       layer_norm_eps



			def __SCREAMING_SNAKE_CASE							(						self   )			->   List[str]:
								__a		 =       floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]   )

								__a		 =       None
								if self.use_labels:
													# create a random int32 tensor of given shape
													__a		 =       ids_tensor([self.batch_size]				,						self.num_labels   )

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



			def __SCREAMING_SNAKE_CASE							(						self   )			->   str:
								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 __SCREAMING_SNAKE_CASE							(						self				,						UpperCAmelCase				,						UpperCAmelCase				,						UpperCAmelCase   )			->   Tuple:
								__a		 =       TFCvtModel(config=SCREAMING_SNAKE_CASE_   )
								__a		 =       model(SCREAMING_SNAKE_CASE_				,						training=SCREAMING_SNAKE_CASE_   )
								__a		 =       (self.image_size, self.image_size)
								__a		 =       image_size[0], image_size[1]
								for i in range(len(self.depth   )   ):
													__a		 =       floor(((height + 2 * self.patch_padding[i] - self.patch_sizes[i]) / self.patch_stride[i]) + 1   )
													__a		 =       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 __SCREAMING_SNAKE_CASE							(						self				,						UpperCAmelCase				,						UpperCAmelCase				,						UpperCAmelCase   )			->   Dict:
								__a		 =       self.num_labels
								__a		 =       TFCvtForImageClassification(SCREAMING_SNAKE_CASE_   )
								__a		 =       model(SCREAMING_SNAKE_CASE_				,						labels=SCREAMING_SNAKE_CASE_				,						training=SCREAMING_SNAKE_CASE_   )
								self.parent.assertEqual(result.logits.shape				,						(self.batch_size, self.num_labels)   )







			def __SCREAMING_SNAKE_CASE							(						self   )			->   Optional[Any]:
								__a		 =       self.prepare_config_and_inputs()
								__a		 =       config_and_inputs
								__a		 =       {"""pixel_values""": pixel_values}
								return config, inputs_dict






@require_tf
class 						a__							(       _UpperCAmelCase				,						_UpperCAmelCase				,						unittest.TestCase		):
			A__    :       str        =      (TFCvtModel, TFCvtForImageClassification) if is_tf_available() else ()
			A__    :       Dict        =      (
			    {'feature-extraction': TFCvtModel, 'image-classification': TFCvtForImageClassification}
			    if is_tf_available()
			    else {}
			)
			A__    :       Union[str, Any]        =      False
			A__    :       Any        =      False
			A__    :       str        =      False
			A__    :       str        =      False
			A__    :       Any        =      False



			def __SCREAMING_SNAKE_CASE							(						self   )			->   Union[str, Any]:
								__a		 =       TFCvtModelTester(self   )
								__a		 =       TFCvtConfigTester(self				,						config_class=SCREAMING_SNAKE_CASE_				,						has_text_modality=SCREAMING_SNAKE_CASE_				,						hidden_size=3_7   )



			def __SCREAMING_SNAKE_CASE							(						self   )			->   Optional[Any]:
								self.config_tester.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()



			@unittest.skip(reason='Cvt does not output attentions'   )
			def __SCREAMING_SNAKE_CASE							(						self   )			->   int:
								pass



			@unittest.skip(reason='Cvt does not use inputs_embeds'   )
			def __SCREAMING_SNAKE_CASE							(						self   )			->   List[str]:
								pass



			@unittest.skip(reason='Cvt does not support input and output embeddings'   )
			def __SCREAMING_SNAKE_CASE							(						self   )			->   str:
								pass



			@unittest.skipIf(
			    not is_tf_available() or len(tf.config.list_physical_devices('GPU'   )   ) == 0				,						reason='TF does not support backprop for grouped convolutions on CPU.'				,						)
			def __SCREAMING_SNAKE_CASE							(						self   )			->   Optional[Any]:
								super().test_dataset_conversion()



			@unittest.skipIf(
			    not is_tf_available() or len(tf.config.list_physical_devices('GPU'   )   ) == 0				,						reason='TF does not support backprop for grouped convolutions on CPU.'				,						)
			@slow
			def __SCREAMING_SNAKE_CASE							(						self   )			->   Dict:
								super().test_keras_fit()



			@unittest.skip(reason='Get `Failed to determine best cudnn convolution algo.` error after using TF 2.12+cuda 11.8'   )
			def __SCREAMING_SNAKE_CASE							(						self   )			->   int:
								__a		 =       tf.keras.mixed_precision.Policy('mixed_float16'   )
								tf.keras.mixed_precision.set_global_policy(SCREAMING_SNAKE_CASE_   )
								super().test_keras_fit()
								tf.keras.mixed_precision.set_global_policy('float32'   )



			def __SCREAMING_SNAKE_CASE							(						self   )			->   Optional[Any]:
								__a		 =       self.model_tester.prepare_config_and_inputs_for_common()

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

													__a		 =       ["""pixel_values"""]
													self.assertListEqual(arg_names[:1]				,						SCREAMING_SNAKE_CASE_   )



			def __SCREAMING_SNAKE_CASE							(						self   )			->   Optional[int]:
								def check_hidden_states_output(UpperCAmelCase				,						UpperCAmelCase				,						UpperCAmelCase   ):
													__a		 =       model_class(SCREAMING_SNAKE_CASE_   )

													__a		 =       model(**self._prepare_for_class(SCREAMING_SNAKE_CASE_				,						SCREAMING_SNAKE_CASE_   )   )
													__a		 =       outputs.hidden_states

													__a		 =       len(self.model_tester.depth   )
													self.assertEqual(len(SCREAMING_SNAKE_CASE_   )				,						SCREAMING_SNAKE_CASE_   )

													# 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,
													    ]				,						)

								__a		 =       self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
													__a		 =       True
													check_hidden_states_output(SCREAMING_SNAKE_CASE_				,						SCREAMING_SNAKE_CASE_				,						SCREAMING_SNAKE_CASE_   )

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

													check_hidden_states_output(SCREAMING_SNAKE_CASE_				,						SCREAMING_SNAKE_CASE_				,						SCREAMING_SNAKE_CASE_   )



			def __SCREAMING_SNAKE_CASE							(						self   )			->   Tuple:
								__a		 =       self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_   )



			def __SCREAMING_SNAKE_CASE							(						self   )			->   Optional[Any]:
								__a		 =       self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_image_classification(*SCREAMING_SNAKE_CASE_   )







			@slow
			def __SCREAMING_SNAKE_CASE							(						self   )			->   str:
								for model_name in TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
													__a		 =       TFCvtModel.from_pretrained(SCREAMING_SNAKE_CASE_   )
													self.assertIsNotNone(SCREAMING_SNAKE_CASE_   )






def 							lowerCAmelCase(     ):
					__a		 =       Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'						)
					return image



@require_tf
@require_vision
class 						a__							(       unittest.TestCase		):



			@cached_property
			def __SCREAMING_SNAKE_CASE							(						self   )			->   Optional[int]:
								return AutoImageProcessor.from_pretrained(TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST[0]   )







			@slow
			def __SCREAMING_SNAKE_CASE							(						self   )			->   Dict:
								__a		 =       TFCvtForImageClassification.from_pretrained(TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST[0]   )

								__a		 =       self.default_image_processor
								__a		 =       prepare_img()
								__a		 =       image_processor(images=SCREAMING_SNAKE_CASE_				,						return_tensors='tf'   )

								# forward pass
								__a		 =       model(**SCREAMING_SNAKE_CASE_   )

								# verify the logits
								__a		 =       tf.TensorShape((1, 1_0_0_0)   )
								self.assertEqual(outputs.logits.shape				,						SCREAMING_SNAKE_CASE_   )

								__a		 =       tf.constant([0.9_285, 0.9_015, -0.3_150]   )
								self.assertTrue(np.allclose(outputs.logits[0, :3].numpy()				,						SCREAMING_SNAKE_CASE_				,						atol=1e-4   )   )





from math import sqrt
def 							lowerCAmelCase(     __lowerCamelCase						):
					__a		 =       0
					for i in range(1				,    int(sqrt(__lowerCamelCase						) + 1						)						):
										if n % i == 0 and i != sqrt(__lowerCamelCase						):
															total += i + n // i
										elif i == sqrt(__lowerCamelCase						):
															total += i
					return total - n
def 							lowerCAmelCase(     __lowerCamelCase = 1_0000						):
					__a		 =       sum(
					    i
					    for i in range(1				,    __lowerCamelCase						)
					    if sum_of_divisors(sum_of_divisors(__lowerCamelCase						)						) == i and sum_of_divisors(__lowerCamelCase						) != i						)
					return total


if __name__ == "__main__":
	print(solution(int(str(input()).strip())))




