






'''simple docstring'''
import inspect
import unittest

from transformers import MobileViTVaConfig
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

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 MobileViTVaForImageClassification, MobileViTVaForSemanticSegmentation, MobileViTVaModel
  from transformers.models.mobilevitva.modeling_mobilevitva import (
      MOBILEVITV2_PRETRAINED_MODEL_ARCHIVE_LIST,
      make_divisible,
  )


if is_vision_available():
  from PIL import Image

  from transformers import MobileViTImageProcessor






class    __SCREAMING_SNAKE_CASE					(	lowerCamelCase ):




 def    __magic_name__		(					self		:							Any					)		->  int:
       SCREAMING_SNAKE_CASE__   : Optional[int]													=self.config_class(**self.inputs_dict					)
       self.parent.assertTrue(hasattr(__lowercase    ,					'''width_multiplier'''					)					)






class    __SCREAMING_SNAKE_CASE					:




 def __init__(					self		:							Tuple    ,					__lowercase		:							str    ,					__lowercase		:							Optional[Any]=13    ,					__lowercase		:							List[str]=64    ,					__lowercase		:							int=2    ,					__lowercase		:							List[str]=3    ,					__lowercase		:							List[Any]="swish"    ,					__lowercase		:							Any=3    ,					__lowercase		:							Optional[int]=32    ,					__lowercase		:							List[Any]=0.1    ,					__lowercase		:							Tuple=0.02    ,					__lowercase		:							List[Any]=True    ,					__lowercase		:							int=True    ,					__lowercase		:							Dict=10    ,					__lowercase		:							Any=None    ,					__lowercase		:							List[str]=0.25    ,					__lowercase		:							str=0.0    ,					__lowercase		:							Tuple=0.0    ,					)		->  List[str]:
       SCREAMING_SNAKE_CASE__   : Any													=parent
       SCREAMING_SNAKE_CASE__   : Union[str, Any]													=batch_size
       SCREAMING_SNAKE_CASE__   : Optional[int]													=image_size
       SCREAMING_SNAKE_CASE__   : str													=patch_size
       SCREAMING_SNAKE_CASE__   : int													=num_channels
       SCREAMING_SNAKE_CASE__   : Optional[Any]													=make_divisible(5_12 * width_multiplier    ,					divisor=8					)
       SCREAMING_SNAKE_CASE__   : Union[str, Any]													=hidden_act
       SCREAMING_SNAKE_CASE__   : int													=conv_kernel_size
       SCREAMING_SNAKE_CASE__   : List[str]													=output_stride
       SCREAMING_SNAKE_CASE__   : str													=classifier_dropout_prob
       SCREAMING_SNAKE_CASE__   : List[Any]													=use_labels
       SCREAMING_SNAKE_CASE__   : Optional[Any]													=is_training
       SCREAMING_SNAKE_CASE__   : List[Any]													=num_labels
       SCREAMING_SNAKE_CASE__   : List[Any]													=initializer_range
       SCREAMING_SNAKE_CASE__   : Optional[Any]													=scope
       SCREAMING_SNAKE_CASE__   : Dict													=width_multiplier
       SCREAMING_SNAKE_CASE__   : Optional[int]													=ffn_dropout
       SCREAMING_SNAKE_CASE__   : Any													=attn_dropout




 def    __magic_name__		(					self		:							Optional[Any]					)		->  Tuple:
       SCREAMING_SNAKE_CASE__   : Dict													=floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]					)

       SCREAMING_SNAKE_CASE__   : Optional[int]													=None
       SCREAMING_SNAKE_CASE__   : str													=None
       if self.use_labels:
             SCREAMING_SNAKE_CASE__   : str													=ids_tensor([self.batch_size]    ,					self.num_labels					)
             SCREAMING_SNAKE_CASE__   : Tuple													=ids_tensor([self.batch_size, self.image_size, self.image_size]    ,					self.num_labels					)

       SCREAMING_SNAKE_CASE__   : Tuple													=self.get_config()

       return config, pixel_values, labels, pixel_labels




 def    __magic_name__		(					self		:							Optional[Any]					)		->  int:
       return MobileViTVaConfig(
           image_size=self.image_size    ,					patch_size=self.patch_size    ,					num_channels=self.num_channels    ,					hidden_act=self.hidden_act    ,					conv_kernel_size=self.conv_kernel_size    ,					output_stride=self.output_stride    ,					classifier_dropout_prob=self.classifier_dropout_prob    ,					initializer_range=self.initializer_range    ,					width_multiplier=self.width_multiplier    ,					ffn_dropout=self.ffn_dropout_prob    ,					attn_dropout=self.attn_dropout_prob    ,					)




 def    __magic_name__		(					self		:							Optional[Any]    ,					__lowercase		:							Optional[Any]    ,					__lowercase		:							List[str]    ,					__lowercase		:							List[Any]    ,					__lowercase		:							List[str]					)		->  Any:
       SCREAMING_SNAKE_CASE__   : Tuple													=MobileViTVaModel(config=__lowercase					)
       model.to(__lowercase					)
       model.eval()
       SCREAMING_SNAKE_CASE__   : Tuple													=model(__lowercase					)
       self.parent.assertEqual(
           result.last_hidden_state.shape    ,					(
               self.batch_size,
               self.last_hidden_size,
               self.image_size // self.output_stride,
               self.image_size // self.output_stride,
           )    ,					)




 def    __magic_name__		(					self		:							List[Any]    ,					__lowercase		:							str    ,					__lowercase		:							int    ,					__lowercase		:							Dict    ,					__lowercase		:							Optional[Any]					)		->  Optional[int]:
       SCREAMING_SNAKE_CASE__   : Tuple													=self.num_labels
       SCREAMING_SNAKE_CASE__   : int													=MobileViTVaForImageClassification(__lowercase					)
       model.to(__lowercase					)
       model.eval()
       SCREAMING_SNAKE_CASE__   : int													=model(__lowercase    ,					labels=__lowercase					)
       self.parent.assertEqual(result.logits.shape    ,					(self.batch_size, self.num_labels)					)




 def    __magic_name__		(					self		:							List[Any]    ,					__lowercase		:							int    ,					__lowercase		:							Optional[Any]    ,					__lowercase		:							Tuple    ,					__lowercase		:							List[str]					)		->  Union[str, Any]:
       SCREAMING_SNAKE_CASE__   : List[str]													=self.num_labels
       SCREAMING_SNAKE_CASE__   : int													=MobileViTVaForSemanticSegmentation(__lowercase					)
       model.to(__lowercase					)
       model.eval()
       SCREAMING_SNAKE_CASE__   : Union[str, Any]													=model(__lowercase					)
       self.parent.assertEqual(
           result.logits.shape    ,					(
               self.batch_size,
               self.num_labels,
               self.image_size // self.output_stride,
               self.image_size // self.output_stride,
           )    ,					)
       SCREAMING_SNAKE_CASE__   : int													=model(__lowercase    ,					labels=__lowercase					)
       self.parent.assertEqual(
           result.logits.shape    ,					(
               self.batch_size,
               self.num_labels,
               self.image_size // self.output_stride,
               self.image_size // self.output_stride,
           )    ,					)




 def    __magic_name__		(					self		:							str					)		->  List[Any]:
       SCREAMING_SNAKE_CASE__   : List[str]													=self.prepare_config_and_inputs()
       SCREAMING_SNAKE_CASE__						,		SCREAMING_SNAKE_CASE__						,		SCREAMING_SNAKE_CASE__						,		SCREAMING_SNAKE_CASE__   : Union[str, Any]													=config_and_inputs
       SCREAMING_SNAKE_CASE__   : str													={'''pixel_values''': pixel_values}
       return config, inputs_dict






@require_torch
class    __SCREAMING_SNAKE_CASE					(	lowerCamelCase		, lowerCamelCase		, unittest.TestCase ):
 snake_case_     							=							(
     (MobileViTVaModel, MobileViTVaForImageClassification, MobileViTVaForSemanticSegmentation)
     if is_torch_available()
     else ()
 )

 snake_case_     							=							(
     {
         """feature-extraction""": MobileViTVaModel,
         """image-classification""": MobileViTVaForImageClassification,
         """image-segmentation""": MobileViTVaForSemanticSegmentation,
     }
     if is_torch_available()
     else {}
 )

 snake_case_     							=							False
 snake_case_     							=							False
 snake_case_     							=							False
 snake_case_     							=							False




 def    __magic_name__		(					self		:							Dict					)		->  List[str]:
       SCREAMING_SNAKE_CASE__   : Dict													=MobileViTVaModelTester(self					)
       SCREAMING_SNAKE_CASE__   : List[str]													=MobileViTVaConfigTester(self    ,					config_class=__lowercase    ,					has_text_modality=__lowercase					)




 def    __magic_name__		(					self		:							Any					)		->  str:
       self.config_tester.run_common_tests()




 @unittest.skip(reason='''MobileViTV2 does not use inputs_embeds'''					)
 def    __magic_name__		(					self		:							Dict					)		->  int:
       pass




 @unittest.skip(reason='''MobileViTV2 does not support input and output embeddings'''					)
 def    __magic_name__		(					self		:							List[str]					)		->  Optional[int]:
       pass




 @unittest.skip(reason='''MobileViTV2 does not output attentions'''					)
 def    __magic_name__		(					self		:							Any					)		->  Union[str, Any]:
       pass




 @require_torch_multi_gpu
 @unittest.skip(reason='''Got `CUDA error: misaligned address` for tests after this one being run.'''					)
 def    __magic_name__		(					self		:							Optional[int]					)		->  List[str]:
       pass




 @unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''					)
 def    __magic_name__		(					self		:							str					)		->  int:
       pass




 def    __magic_name__		(					self		:							Any					)		->  str:
       SCREAMING_SNAKE_CASE__						,		SCREAMING_SNAKE_CASE__   : Tuple													=self.model_tester.prepare_config_and_inputs_for_common()

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

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




 def    __magic_name__		(					self		:							str					)		->  List[Any]:
       SCREAMING_SNAKE_CASE__   : List[str]													=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*__lowercase					)




 def    __magic_name__		(					self		:							Any					)		->  Optional[int]:






       def check_hidden_states_output(__lowercase		:							int    ,					__lowercase		:							Tuple    ,					__lowercase		:							Any					):
             SCREAMING_SNAKE_CASE__   : List[str]													=model_class(__lowercase					)
             model.to(__lowercase					)
             model.eval()

             with torch.no_grad():
                   SCREAMING_SNAKE_CASE__   : Optional[Any]													=model(**self._prepare_for_class(__lowercase    ,					__lowercase					)					)

             SCREAMING_SNAKE_CASE__   : List[str]													=outputs.hidden_states

             SCREAMING_SNAKE_CASE__   : Optional[int]													=5
             self.assertEqual(len(__lowercase					)    ,					__lowercase					)

             # MobileViTV2's feature maps are of shape (batch_size, num_channels, height, width)
             # with the width and height being successively divided by 2.
             SCREAMING_SNAKE_CASE__   : int													=2
             for i in range(len(__lowercase					)					):
                   self.assertListEqual(
                       list(hidden_states[i].shape[-2:]					)    ,					[self.model_tester.image_size // divisor, self.model_tester.image_size // divisor]    ,					)
                   divisor *= 2

             self.assertEqual(self.model_tester.output_stride    ,					divisor // 2					)

       SCREAMING_SNAKE_CASE__						,		SCREAMING_SNAKE_CASE__   : Dict													=self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
             SCREAMING_SNAKE_CASE__   : int													=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__   : Optional[int]													=True

             check_hidden_states_output(__lowercase    ,					__lowercase    ,					__lowercase					)




 def    __magic_name__		(					self		:							Optional[int]					)		->  Dict:
       SCREAMING_SNAKE_CASE__   : Any													=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_image_classification(*__lowercase					)




 def    __magic_name__		(					self		:							List[Any]					)		->  Any:
       SCREAMING_SNAKE_CASE__   : List[str]													=self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_semantic_segmentation(*__lowercase					)




 @slow
 def    __magic_name__		(					self		:							str					)		->  Optional[Any]:






       for model_name in MOBILEVITV2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             SCREAMING_SNAKE_CASE__   : str													=MobileViTVaModel.from_pretrained(__lowercase					)
             self.assertIsNotNone(__lowercase					)





def        _a(     ):




      '''simple docstring'''






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







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




 @cached_property
 def    __magic_name__		(					self		:							List[str]					)		->  Tuple:
       return (
           MobileViTImageProcessor.from_pretrained('''apple/mobilevitv2-1.0-imagenet1k-256'''					)
           if is_vision_available()
           else None
       )




 @slow
 def    __magic_name__		(					self		:							Tuple					)		->  List[str]:
       SCREAMING_SNAKE_CASE__   : Dict													=MobileViTVaForImageClassification.from_pretrained('''apple/mobilevitv2-1.0-imagenet1k-256'''					).to(
           __lowercase					)

       SCREAMING_SNAKE_CASE__   : List[str]													=self.default_image_processor
       SCREAMING_SNAKE_CASE__   : Optional[int]													=prepare_img()
       SCREAMING_SNAKE_CASE__   : List[str]													=image_processor(images=__lowercase    ,					return_tensors='''pt'''					).to(__lowercase					)

       # forward pass
       with torch.no_grad():
             SCREAMING_SNAKE_CASE__   : List[str]													=model(**__lowercase					)

       # verify the logits
       SCREAMING_SNAKE_CASE__   : Dict													=torch.Size((1, 10_00)					)
       self.assertEqual(outputs.logits.shape    ,					__lowercase					)

       SCREAMING_SNAKE_CASE__   : Dict													=torch.tensor([-1.6336e00, -7.3204e-02, -5.1883e-01]					).to(__lowercase					)

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




 @slow
 def    __magic_name__		(					self		:							List[Any]					)		->  str:
       SCREAMING_SNAKE_CASE__   : str													=MobileViTVaForSemanticSegmentation.from_pretrained('''shehan97/mobilevitv2-1.0-voc-deeplabv3'''					)
       SCREAMING_SNAKE_CASE__   : List[Any]													=model.to(__lowercase					)

       SCREAMING_SNAKE_CASE__   : List[str]													=MobileViTImageProcessor.from_pretrained('''shehan97/mobilevitv2-1.0-voc-deeplabv3'''					)

       SCREAMING_SNAKE_CASE__   : Tuple													=prepare_img()
       SCREAMING_SNAKE_CASE__   : str													=image_processor(images=__lowercase    ,					return_tensors='''pt'''					).to(__lowercase					)

       # forward pass
       with torch.no_grad():
             SCREAMING_SNAKE_CASE__   : Dict													=model(**__lowercase					)
       SCREAMING_SNAKE_CASE__   : Dict													=outputs.logits

       # verify the logits
       SCREAMING_SNAKE_CASE__   : Any													=torch.Size((1, 21, 32, 32)					)
       self.assertEqual(logits.shape    ,					__lowercase					)

       SCREAMING_SNAKE_CASE__   : Tuple													=torch.tensor(
           [
               [[7.0863, 7.1525, 6.8201], [6.6931, 6.8770, 6.8933], [6.2978, 7.0366, 6.9636]],
               [[-3.7134, -3.6712, -3.6675], [-3.5825, -3.3549, -3.4777], [-3.3435, -3.3979, -3.2857]],
               [[-2.9329, -2.8003, -2.7369], [-3.0564, -2.4780, -2.0207], [-2.6889, -1.9298, -1.7640]],
           ]    ,					device=__lowercase    ,					)

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




 @slow
 def    __magic_name__		(					self		:							Dict					)		->  Tuple:
       SCREAMING_SNAKE_CASE__   : Any													=MobileViTVaForSemanticSegmentation.from_pretrained('''shehan97/mobilevitv2-1.0-voc-deeplabv3'''					)
       SCREAMING_SNAKE_CASE__   : int													=model.to(__lowercase					)

       SCREAMING_SNAKE_CASE__   : Optional[int]													=MobileViTImageProcessor.from_pretrained('''shehan97/mobilevitv2-1.0-voc-deeplabv3'''					)

       SCREAMING_SNAKE_CASE__   : List[Any]													=prepare_img()
       SCREAMING_SNAKE_CASE__   : List[Any]													=image_processor(images=__lowercase    ,					return_tensors='''pt'''					).to(__lowercase					)

       # forward pass
       with torch.no_grad():
             SCREAMING_SNAKE_CASE__   : List[str]													=model(**__lowercase					)

       SCREAMING_SNAKE_CASE__   : Dict													=outputs.logits.detach().cpu()

       SCREAMING_SNAKE_CASE__   : List[Any]													=image_processor.post_process_semantic_segmentation(outputs=__lowercase    ,					target_sizes=[(50, 60)]					)
       SCREAMING_SNAKE_CASE__   : Union[str, Any]													=torch.Size((50, 60)					)
       self.assertEqual(segmentation[0].shape    ,					__lowercase					)

       SCREAMING_SNAKE_CASE__   : Optional[int]													=image_processor.post_process_semantic_segmentation(outputs=__lowercase					)
       SCREAMING_SNAKE_CASE__   : List[Any]													=torch.Size((32, 32)					)
       self.assertEqual(segmentation[0].shape    ,					__lowercase					)


def      a      (			A__	:   int = 1000000     )    ->      int:





      """simple docstring"""



      _lowercase	       =1
      _lowercase	       =1
      _lowercase	       ={1: 1}

      for inputa in range(2      ,   A__     ):
            _lowercase	       =0
            _lowercase	       =inputa

            while True:
                  if number in counters:
                        counter += counters[number]
                        break
                  if number % 2 == 0:
                        number //= 2
                        counter += 1
                  else:
                        _lowercase	       =(3 * number) + 1
                        counter += 1

            if inputa not in counters:
                  _lowercase	       =counter

            if counter > pre_counter:
                  _lowercase	       =inputa
                  _lowercase	       =counter
      return largest_number


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


