


"""simple docstring"""






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     __lowerCamelCase  (					a__				):

					'''simple docstring'''


					def 							_UpperCAmelCase      (      self							)       ->							Optional[Any]:
										_a    	=				self.config_class(**self.inputs_dict							)
										self.parent.assertTrue(hasattr(lowerCAmelCase__    ,				'''embed_dim'''							)							)
										self.parent.assertTrue(hasattr(lowerCAmelCase__    ,				'''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-1_2    ,				__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 							_UpperCAmelCase      (      self							)       ->							Any:
										_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 							_UpperCAmelCase      (      self							)       ->							List[Any]:
										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 							_UpperCAmelCase      (      self    ,				__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase							)       ->							Optional[int]:
										_a    	=				TFCvtModel(config=lowerCAmelCase__							)
										_a    	=				model(lowerCAmelCase__    ,				training=lowerCAmelCase__							)
										_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 							_UpperCAmelCase      (      self    ,				__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase							)       ->							Dict:
										_a    	=				self.num_labels
										_a    	=				TFCvtForImageClassification(lowerCAmelCase__							)
										_a    	=				model(lowerCAmelCase__    ,				labels=lowerCAmelCase__    ,				training=lowerCAmelCase__							)
										self.parent.assertEqual(result.logits.shape    ,				(self.batch_size, self.num_labels)							)





					def 							_UpperCAmelCase      (      self							)       ->							Tuple:
										_a    	=				self.prepare_config_and_inputs()
										_a    	=				config_and_inputs
										_a    	=				{"pixel_values": pixel_values}
										return config, inputs_dict







@require_tf
class     __lowerCamelCase  (					a__  ,					a__  ,					unittest.TestCase				):

					'''simple docstring'''
					A_       :	List[str]    =		(TFCvtModel, TFCvtForImageClassification) if is_tf_available() else ()
					A_       :	List[Any]    =		(
					    {"""feature-extraction""": TFCvtModel, """image-classification""": TFCvtForImageClassification}
					    if is_tf_available()
					    else {}
					)
					A_       :	Optional[Any]    =		False
					A_       :	List[str]    =		False
					A_       :	Optional[Any]    =		False
					A_       :	int    =		False
					A_       :	Dict    =		False


					def 							_UpperCAmelCase      (      self							)       ->							Optional[int]:
										_a    	=				TFCvtModelTester(self							)
										_a    	=				TFCvtConfigTester(self    ,				config_class=lowerCAmelCase__    ,				has_text_modality=lowerCAmelCase__    ,				hidden_size=37							)


					def 							_UpperCAmelCase      (      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 							_UpperCAmelCase      (      self							)       ->							Dict:
										pass


					@unittest.skip(reason='''Cvt does not use inputs_embeds'''							)
					def 							_UpperCAmelCase      (      self							)       ->							Union[str, Any]:
										pass


					@unittest.skip(reason='''Cvt does not support input and output embeddings'''							)
					def 							_UpperCAmelCase      (      self							)       ->							Union[str, Any]:
										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 							_UpperCAmelCase      (      self							)       ->							List[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 							_UpperCAmelCase      (      self							)       ->							Optional[int]:
										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 							_UpperCAmelCase      (      self							)       ->							int:
										_a    	=				tf.keras.mixed_precision.Policy('''mixed_float16'''							)
										tf.keras.mixed_precision.set_global_policy(lowerCAmelCase__							)
										super().test_keras_fit()
										tf.keras.mixed_precision.set_global_policy('''float32'''							)


					def 							_UpperCAmelCase      (      self							)       ->							Any:
										_a    	=				self.model_tester.prepare_config_and_inputs_for_common()

										for model_class in self.all_model_classes:
															_a    	=				model_class(lowerCAmelCase__							)
															_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]    ,				lowerCAmelCase__							)


					def 							_UpperCAmelCase      (      self							)       ->							int:
										def check_hidden_states_output(__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase							):
															_a    	=				model_class(lowerCAmelCase__							)

															_a    	=				model(**self._prepare_for_class(lowerCAmelCase__    ,				lowerCAmelCase__							)							)
															_a    	=				outputs.hidden_states

															_a    	=				len(self.model_tester.depth							)
															self.assertEqual(len(lowerCAmelCase__							)    ,				lowerCAmelCase__							)

															# 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(lowerCAmelCase__    ,				lowerCAmelCase__    ,				lowerCAmelCase__							)

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

															check_hidden_states_output(lowerCAmelCase__    ,				lowerCAmelCase__    ,				lowerCAmelCase__							)


					def 							_UpperCAmelCase      (      self							)       ->							Union[str, Any]:
										_a    	=				self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*lowerCAmelCase__							)


					def 							_UpperCAmelCase      (      self							)       ->							Any:
										_a    	=				self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_image_classification(*lowerCAmelCase__							)





					@slow
					def 							_UpperCAmelCase      (      self							)       ->							str:
										for model_name in TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															_a    	=				TFCvtModel.from_pretrained(lowerCAmelCase__							)
															self.assertIsNotNone(lowerCAmelCase__							)







def       A_   (   ):






					"""simple docstring"""

					_a    	=				Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''       )
					return image


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

					'''simple docstring'''


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





					@slow
					def 							_UpperCAmelCase      (      self							)       ->							Optional[Any]:
										_a    	=				TFCvtForImageClassification.from_pretrained(TF_CVT_PRETRAINED_MODEL_ARCHIVE_LIST[0]							)

										_a    	=				self.default_image_processor
										_a    	=				prepare_img()
										_a    	=				image_processor(images=lowerCAmelCase__    ,				return_tensors='''tf'''							)

										# forward pass
										_a    	=				model(**lowerCAmelCase__							)

										# verify the logits
										_a    	=				tf.TensorShape((1, 1000)							)
										self.assertEqual(outputs.logits.shape    ,				lowerCAmelCase__							)

										_a    	=				tf.constant([0.9285, 0.9015, -0.3150]							)
										self.assertTrue(np.allclose(outputs.logits[0, :3].numpy()    ,				lowerCAmelCase__    ,				atol=1e-4							)							)



"""simple docstring"""






def       A_   (   _lowerCAmelCase     :					int = 10_00       ):






     """simple docstring"""

     _a	,      _a    	=				1, 1
     _a    	=				2
     while True:
          _a    	=				0
          _a    	=				fa + fa
          _a	,      _a    	=				fa, f
          index += 1
          for _ in str(_lowerCAmelCase       ):
               i += 1
          if i == n:
               break
     return index


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