



import collections
import inspect
import unittest

from transformers import DinatConfig
from transformers.testing_utils import require_natten, require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

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


if is_torch_available():
    import torch
    from torch import nn

    from transformers import DinatBackbone, DinatForImageClassification, DinatModel
    from transformers.models.dinat.modeling_dinat import DINAT_PRETRAINED_MODEL_ARCHIVE_LIST

if is_vision_available():
    from PIL import Image

    from transformers import AutoImageProcessor





class 		UpperCAmelCase    :





   def __init__(						self							,  _lowerCAmelCase							,  _lowerCAmelCase=13							,  _lowerCAmelCase=64							,  _lowerCAmelCase=4							,  _lowerCAmelCase=3							,  _lowerCAmelCase=16							,  _lowerCAmelCase=[1, 2, 1]							,  _lowerCAmelCase=[2, 4, 8]							,  _lowerCAmelCase=3							,  _lowerCAmelCase=[[3], [1, 2], [1]]							,  _lowerCAmelCase=2.0							,  _lowerCAmelCase=True							,  _lowerCAmelCase=0.0							,  _lowerCAmelCase=0.0							,  _lowerCAmelCase=0.1							,  _lowerCAmelCase="gelu"							,  _lowerCAmelCase=True							,  _lowerCAmelCase=0.02							,  _lowerCAmelCase=1E-5							,  _lowerCAmelCase=True							,  _lowerCAmelCase=None							,  _lowerCAmelCase=True							,  _lowerCAmelCase=10							,  _lowerCAmelCase=["stage1", "stage2"]							,  _lowerCAmelCase=[1, 2]							,  ):
         _lowerCAmelCase			      =	parent
         _lowerCAmelCase			      =	batch_size
         _lowerCAmelCase			      =	image_size
         _lowerCAmelCase			      =	patch_size
         _lowerCAmelCase			      =	num_channels
         _lowerCAmelCase			      =	embed_dim
         _lowerCAmelCase			      =	depths
         _lowerCAmelCase			      =	num_heads
         _lowerCAmelCase			      =	kernel_size
         _lowerCAmelCase			      =	dilations
         _lowerCAmelCase			      =	mlp_ratio
         _lowerCAmelCase			      =	qkv_bias
         _lowerCAmelCase			      =	hidden_dropout_prob
         _lowerCAmelCase			      =	attention_probs_dropout_prob
         _lowerCAmelCase			      =	drop_path_rate
         _lowerCAmelCase			      =	hidden_act
         _lowerCAmelCase			      =	patch_norm
         _lowerCAmelCase			      =	layer_norm_eps
         _lowerCAmelCase			      =	initializer_range
         _lowerCAmelCase			      =	is_training
         _lowerCAmelCase			      =	scope
         _lowerCAmelCase			      =	use_labels
         _lowerCAmelCase			      =	num_labels
         _lowerCAmelCase			      =	out_features
         _lowerCAmelCase			      =	out_indices





   def 						__lowerCAmelCase				(						self      ):
         _lowerCAmelCase			      =	floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]      )

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

         _lowerCAmelCase			      =	self.get_config()

         return config, pixel_values, labels





   def 						__lowerCAmelCase				(						self      ):
         return DinatConfig(
             num_labels=self.num_labels							,  image_size=self.image_size							,  patch_size=self.patch_size							,  num_channels=self.num_channels							,  embed_dim=self.embed_dim							,  depths=self.depths							,  num_heads=self.num_heads							,  kernel_size=self.kernel_size							,  dilations=self.dilations							,  mlp_ratio=self.mlp_ratio							,  qkv_bias=self.qkv_bias							,  hidden_dropout_prob=self.hidden_dropout_prob							,  attention_probs_dropout_prob=self.attention_probs_dropout_prob							,  drop_path_rate=self.drop_path_rate							,  hidden_act=self.hidden_act							,  patch_norm=self.patch_norm							,  layer_norm_eps=self.layer_norm_eps							,  initializer_range=self.initializer_range							,  out_features=self.out_features							,  out_indices=self.out_indices							,  )





   def 						__lowerCAmelCase				(						self							,  _lowerCAmelCase							,  _lowerCAmelCase							,  _lowerCAmelCase      ):
         _lowerCAmelCase			      =	DinatModel(config=_lowerCAmelCase      )
         model.to(_lowerCAmelCase      )
         model.eval()
         _lowerCAmelCase			      =	model(_lowerCAmelCase      )

         _lowerCAmelCase			      =	(config.image_size // config.patch_size) // (2 ** (len(config.depths      ) - 1))
         _lowerCAmelCase			      =	int(config.embed_dim * 2 ** (len(config.depths      ) - 1)      )

         self.parent.assertEqual(
             result.last_hidden_state.shape							,  (self.batch_size, expected_height, expected_width, expected_dim)      )





   def 						__lowerCAmelCase				(						self							,  _lowerCAmelCase							,  _lowerCAmelCase							,  _lowerCAmelCase      ):
         _lowerCAmelCase			      =	DinatForImageClassification(_lowerCAmelCase      )
         model.to(_lowerCAmelCase      )
         model.eval()
         _lowerCAmelCase			      =	model(_lowerCAmelCase							,  labels=_lowerCAmelCase      )
         self.parent.assertEqual(result.logits.shape							,  (self.batch_size, self.num_labels)      )

         # test greyscale images
         _lowerCAmelCase			      =	1
         _lowerCAmelCase			      =	DinatForImageClassification(_lowerCAmelCase      )
         model.to(_lowerCAmelCase      )
         model.eval()

         _lowerCAmelCase			      =	floats_tensor([self.batch_size, 1, self.image_size, self.image_size]      )
         _lowerCAmelCase			      =	model(_lowerCAmelCase      )
         self.parent.assertEqual(result.logits.shape							,  (self.batch_size, self.num_labels)      )





   def 						__lowerCAmelCase				(						self							,  _lowerCAmelCase							,  _lowerCAmelCase							,  _lowerCAmelCase      ):
         _lowerCAmelCase			      =	DinatBackbone(config=_lowerCAmelCase      )
         model.to(_lowerCAmelCase      )
         model.eval()
         _lowerCAmelCase			      =	model(_lowerCAmelCase      )

         # verify hidden states
         self.parent.assertEqual(len(result.feature_maps      )							,  len(config.out_features      )      )
         self.parent.assertListEqual(list(result.feature_maps[0].shape      )							,  [self.batch_size, model.channels[0], 16, 16]      )

         # verify channels
         self.parent.assertEqual(len(model.channels      )							,  len(config.out_features      )      )

         # verify backbone works with out_features=None
         _lowerCAmelCase			      =	None
         _lowerCAmelCase			      =	DinatBackbone(config=_lowerCAmelCase      )
         model.to(_lowerCAmelCase      )
         model.eval()
         _lowerCAmelCase			      =	model(_lowerCAmelCase      )

         # verify feature maps
         self.parent.assertEqual(len(result.feature_maps      )							,  1      )
         self.parent.assertListEqual(list(result.feature_maps[0].shape      )							,  [self.batch_size, model.channels[-1], 4, 4]      )

         # verify channels
         self.parent.assertEqual(len(model.channels      )							,  1      )





   def 						__lowerCAmelCase				(						self      ):
         _lowerCAmelCase			      =	self.prepare_config_and_inputs()
         _lowerCAmelCase			      =	config_and_inputs
         _lowerCAmelCase			      =	{"pixel_values": pixel_values}
         return config, inputs_dict






@require_natten
@require_torch
class 		UpperCAmelCase    (    snake_case_							,snake_case_							,unittest.TestCase					):
   SCREAMING_SNAKE_CASE__					      =  (
       (
           DinatModel,
           DinatForImageClassification,
           DinatBackbone,
       )
       if is_torch_available()
       else ()
   )
   SCREAMING_SNAKE_CASE__					      =  (
       {'''feature-extraction''': DinatModel, '''image-classification''': DinatForImageClassification}
       if is_torch_available()
       else {}
   )
   SCREAMING_SNAKE_CASE__					      =  False

   SCREAMING_SNAKE_CASE__					      =  False
   SCREAMING_SNAKE_CASE__					      =  False
   SCREAMING_SNAKE_CASE__					      =  False
   SCREAMING_SNAKE_CASE__					      =  False





   def 						__lowerCAmelCase				(						self      ):
         _lowerCAmelCase			      =	DinatModelTester(self      )
         _lowerCAmelCase			      =	ConfigTester(self							,  config_class=_lowerCAmelCase							,  embed_dim=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





   def 						__lowerCAmelCase				(						self      ):
         _lowerCAmelCase			      =	self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*_lowerCAmelCase      )





   def 						__lowerCAmelCase				(						self      ):
         _lowerCAmelCase			      =	self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_image_classification(*_lowerCAmelCase      )





   def 						__lowerCAmelCase				(						self      ):
         _lowerCAmelCase			      =	self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_backbone(*_lowerCAmelCase      )





   @unittest.skip(reason='''Dinat does not use inputs_embeds'''      )
   def 						__lowerCAmelCase				(						self      ):
         pass





   @unittest.skip(reason='''Dinat does not use feedforward chunking'''      )
   def 						__lowerCAmelCase				(						self      ):
         pass





   def 						__lowerCAmelCase				(						self      ):
         _lowerCAmelCase			      =	self.model_tester.prepare_config_and_inputs_for_common()

         for model_class in self.all_model_classes:
               _lowerCAmelCase			      =	model_class(_lowerCAmelCase      )
               self.assertIsInstance(model.get_input_embeddings()							,  (nn.Module)      )
               _lowerCAmelCase			      =	model.get_output_embeddings()
               self.assertTrue(x is None or isinstance(_lowerCAmelCase							,  nn.Linear      )      )





   def 						__lowerCAmelCase				(						self      ):
         _lowerCAmelCase			      =	self.model_tester.prepare_config_and_inputs_for_common()

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

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





   def 						__lowerCAmelCase				(						self      ):
         self.skipTest('''Dinat\'s attention operation is handled entirely by NATTEN.'''      )





   def 						__lowerCAmelCase				(						self							,  _lowerCAmelCase							,  _lowerCAmelCase							,  _lowerCAmelCase							,  _lowerCAmelCase      ):
         _lowerCAmelCase			      =	model_class(_lowerCAmelCase      )
         model.to(_lowerCAmelCase      )
         model.eval()

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

         _lowerCAmelCase			      =	outputs.hidden_states

         _lowerCAmelCase			      =	getattr(
             self.model_tester							,  '''expected_num_hidden_layers'''							,  len(self.model_tester.depths      ) + 1      )
         self.assertEqual(len(_lowerCAmelCase      )							,  _lowerCAmelCase      )

         # Dinat has a different seq_length
         _lowerCAmelCase			      =	(
             config.patch_size
             if isinstance(config.patch_size							,  collections.abc.Iterable      )
             else (config.patch_size, config.patch_size)
         )

         _lowerCAmelCase			      =	image_size[0] // patch_size[0]
         _lowerCAmelCase			      =	image_size[1] // patch_size[1]

         self.assertListEqual(
             list(hidden_states[0].shape[-3:]      )							,  [height, width, self.model_tester.embed_dim]							,  )

         if model_class.__name__ != "DinatBackbone":
               _lowerCAmelCase			      =	outputs.reshaped_hidden_states
               self.assertEqual(len(_lowerCAmelCase      )							,  _lowerCAmelCase      )

               _lowerCAmelCase			      =	reshaped_hidden_states[0].shape
               _lowerCAmelCase			      =	(
                   reshaped_hidden_states[0].view(_lowerCAmelCase							,  _lowerCAmelCase							,  _lowerCAmelCase							,  _lowerCAmelCase      ).permute(0							,  2							,  3							,  1      )
               )
               self.assertListEqual(
                   list(reshaped_hidden_states.shape[-3:]      )							,  [height, width, self.model_tester.embed_dim]							,  )





   def 						__lowerCAmelCase				(						self      ):
         _lowerCAmelCase			      =	self.model_tester.prepare_config_and_inputs_for_common()

         _lowerCAmelCase			      =	(
             self.model_tester.image_size
             if isinstance(self.model_tester.image_size							,  collections.abc.Iterable      )
             else (self.model_tester.image_size, self.model_tester.image_size)
         )

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

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

               self.check_hidden_states_output(_lowerCAmelCase							,  _lowerCAmelCase							,  _lowerCAmelCase							,  _lowerCAmelCase      )





   @slow
   def 						__lowerCAmelCase				(						self      ):
         for model_name in DINAT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               _lowerCAmelCase			      =	DinatModel.from_pretrained(_lowerCAmelCase      )
               self.assertIsNotNone(_lowerCAmelCase      )





   def 						__lowerCAmelCase				(						self      ):
         _lowerCAmelCase			      =	self.model_tester.prepare_config_and_inputs_for_common()

         _lowerCAmelCase			      =	_config_zero_init(_lowerCAmelCase      )
         for model_class in self.all_model_classes:
               _lowerCAmelCase			      =	model_class(config=_lowerCAmelCase      )
               for name, param in model.named_parameters():
                     if "embeddings" not in name and param.requires_grad:
                           self.assertIn(
                               ((param.data.mean() * 1E9).round() / 1E9).item()							,  [0.0, 1.0]							,  msg=F'''Parameter {name} of model {model_class} seems not properly initialized'''							,  )






@require_natten
@require_vision
@require_torch
class 		UpperCAmelCase    (    unittest.TestCase					):





   @cached_property
   def 						__lowerCAmelCase				(						self      ):
         return AutoImageProcessor.from_pretrained('''shi-labs/dinat-mini-in1k-224'''      ) if is_vision_available() else None





   @slow
   def 						__lowerCAmelCase				(						self      ):
         _lowerCAmelCase			      =	DinatForImageClassification.from_pretrained('''shi-labs/dinat-mini-in1k-224'''      ).to(_lowerCAmelCase      )
         _lowerCAmelCase			      =	self.default_image_processor

         _lowerCAmelCase			      =	Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''      )
         _lowerCAmelCase			      =	image_processor(images=_lowerCAmelCase							,  return_tensors='''pt'''      ).to(_lowerCAmelCase      )

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

         # verify the logits
         _lowerCAmelCase			      =	torch.Size((1, 1_000)      )
         self.assertEqual(outputs.logits.shape							,  _lowerCAmelCase      )
         _lowerCAmelCase			      =	torch.tensor([-0.1_545, -0.7_667, 0.4_642]      ).to(_lowerCAmelCase      )
         self.assertTrue(torch.allclose(outputs.logits[0, :3]							,  _lowerCAmelCase							,  atol=1E-4      )      )






@require_torch
@require_natten
class 		UpperCAmelCase    (    unittest.TestCase							,snake_case_					):
   SCREAMING_SNAKE_CASE__					      =  (DinatBackbone,) if is_torch_available() else ()
   SCREAMING_SNAKE_CASE__					      =  DinatConfig





   def 						__lowerCAmelCase				(						self      ):
         _lowerCAmelCase			      =	DinatModelTester(self      )




import argparse
import json
import re
from pathlib import Path

import requests
import torch
from huggingface_hub import hf_hub_download
from PIL import Image

from transformers import (
    MobileNetVaConfig,
    MobileNetVaForImageClassification,
    MobileNetVaForSemanticSegmentation,
    MobileNetVaImageProcessor,
    load_tf_weights_in_mobilenet_va,
)
from transformers.utils import logging


logging.set_verbosity_info()
_lowerCamelCase         =	logging.get_logger(__name__)






def 						_lowerCAmelCase    (					__lowerCamelCase :  Union[str, Any]  ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE							:     Dict							=						MobileNetVaConfig(layer_norm_eps=0.001  )

 if "quant" in model_name:
  raise ValueError("Quantized models are not supported."  )

 __SCREAMING_SNAKE_CASE							:     Tuple							=						re.match(r"^.*mobilenet_v2_([^_]*)_([^_]*)$"		,						__lowerCamelCase  )
 if matches:
  __SCREAMING_SNAKE_CASE							:     Union[str, Any]							=						float(matches[1]  )
  __SCREAMING_SNAKE_CASE							:     str							=						int(matches[2]  )

 if model_name.startswith("deeplabv3_"  ):
  __SCREAMING_SNAKE_CASE							:     Union[str, Any]							=						8
  __SCREAMING_SNAKE_CASE							:     Dict							=						21
  __SCREAMING_SNAKE_CASE							:     Tuple							=						"pascal-voc-id2label.json"
 else:
  # The TensorFlow version of MobileNetV2 predicts 1001 classes instead
  # of the usual 1000. The first class (index 0) is "background".
  __SCREAMING_SNAKE_CASE							:     int							=						1001
  __SCREAMING_SNAKE_CASE							:     Dict							=						"imagenet-1k-id2label.json"

 __SCREAMING_SNAKE_CASE							:     List[Any]							=						"huggingface/label-files"
 __SCREAMING_SNAKE_CASE							:     Optional[Any]							=						json.load(open(hf_hub_download(__lowerCamelCase		,						__lowerCamelCase		,						repo_type="dataset"  )		,						"r"  )  )

 if config.num_labels == 1001:
  __SCREAMING_SNAKE_CASE							:     int							=						{int(__lowerCamelCase  ) + 1: v for k, v in idalabel.items()}
  __SCREAMING_SNAKE_CASE							:     int							=						"background"
 else:
  __SCREAMING_SNAKE_CASE							:     Any							=						{int(__lowerCamelCase  ): v for k, v in idalabel.items()}

 __SCREAMING_SNAKE_CASE							:     str							=						idalabel
 __SCREAMING_SNAKE_CASE							:     Tuple							=						{v: k for k, v in idalabel.items()}

 return config






def 						_lowerCAmelCase    (					):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE							:     Dict							=						"http://images.cocodataset.org/val2017/000000039769.jpg"
 __SCREAMING_SNAKE_CASE							:     Any							=						Image.open(requests.get(__lowerCamelCase		,						stream=__lowerCamelCase  ).raw  )
 return im






@torch.no_grad()
def 						_lowerCAmelCase    (					__lowerCamelCase :  str		,						__lowerCamelCase :  Optional[Any]		,						__lowerCamelCase :  Optional[Any]		,						__lowerCamelCase :  Tuple=False  ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE							:     Any							=						get_mobilenet_va_config(__lowerCamelCase  )

 # Load 🤗 model
 if model_name.startswith("deeplabv3_"  ):
  __SCREAMING_SNAKE_CASE							:     Union[str, Any]							=						MobileNetVaForSemanticSegmentation(__lowerCamelCase  ).eval()
 else:
  __SCREAMING_SNAKE_CASE							:     str							=						MobileNetVaForImageClassification(__lowerCamelCase  ).eval()

 # Load weights from TensorFlow checkpoint
 load_tf_weights_in_mobilenet_va(__lowerCamelCase		,						__lowerCamelCase		,						__lowerCamelCase  )

 # Check outputs on an image, prepared by MobileNetV2ImageProcessor
 __SCREAMING_SNAKE_CASE							:     Tuple							=						MobileNetVaImageProcessor(
     crop_size={"width": config.image_size, "height": config.image_size}		,						size={"shortest_edge": config.image_size + 32}		,						)
 __SCREAMING_SNAKE_CASE							:     Any							=						image_processor(images=prepare_img()		,						return_tensors="pt"  )
 __SCREAMING_SNAKE_CASE							:     List[str]							=						model(**__lowerCamelCase  )
 __SCREAMING_SNAKE_CASE							:     Any							=						outputs.logits

 if model_name.startswith("deeplabv3_"  ):
  assert logits.shape == (1, 21, 65, 65)

  if model_name == "deeplabv3_mobilenet_v2_1.0_513":
   __SCREAMING_SNAKE_CASE							:     List[Any]							=						torch.tensor(
       [
           [[17.5790, 17.7581, 18.3355], [18.3257, 18.4230, 18.8973], [18.6169, 18.8650, 19.2187]],
           [[-2.1595, -2.0977, -2.3741], [-2.4226, -2.3028, -2.6835], [-2.7819, -2.5991, -2.7706]],
           [[4.2058, 4.8317, 4.7638], [4.4136, 5.0361, 4.9383], [4.5028, 4.9644, 4.8734]],
       ]  )

  else:
   raise ValueError(F"""Unknown model name: {model_name}"""  )

  assert torch.allclose(logits[0, :3, :3, :3]		,						__lowerCamelCase		,						atol=1E-4  )
 else:
  assert logits.shape == (1, 1001)

  if model_name == "mobilenet_v2_1.4_224":
   __SCREAMING_SNAKE_CASE							:     Optional[Any]							=						torch.tensor([0.0181, -1.0015, 0.4688]  )
  elif model_name == "mobilenet_v2_1.0_224":
   __SCREAMING_SNAKE_CASE							:     str							=						torch.tensor([0.2445, -1.1993, 0.1905]  )
  elif model_name == "mobilenet_v2_0.75_160":
   __SCREAMING_SNAKE_CASE							:     int							=						torch.tensor([0.2482, 0.4136, 0.6669]  )
  elif model_name == "mobilenet_v2_0.35_96":
   __SCREAMING_SNAKE_CASE							:     Any							=						torch.tensor([0.1451, -0.4624, 0.7192]  )
  else:
   __SCREAMING_SNAKE_CASE							:     Optional[int]							=						None

  if expected_logits is not None:
   assert torch.allclose(logits[0, :3]		,						__lowerCamelCase		,						atol=1E-4  )

 Path(__lowerCamelCase  ).mkdir(exist_ok=__lowerCamelCase  )
 print(F"""Saving model {model_name} to {pytorch_dump_folder_path}"""  )
 model.save_pretrained(__lowerCamelCase  )
 print(F"""Saving image processor to {pytorch_dump_folder_path}"""  )
 image_processor.save_pretrained(__lowerCamelCase  )

 if push_to_hub:
  print("Pushing to the hub..."  )
  __SCREAMING_SNAKE_CASE							:     Tuple							=						"google/" + model_name
  image_processor.push_to_hub(__lowerCamelCase  )
  model.push_to_hub(__lowerCamelCase  )


if __name__ == "__main__":
      _lowerCamelCase         =	argparse.ArgumentParser()
      # Required parameters
      parser.add_argument(
          """--model_name""",
          default="""mobilenet_v2_1.0_224""",
          type=str,
          help="""Name of the MobileNetV2 model you'd like to convert. Should in the form 'mobilenet_v2_<depth>_<size>'.""",
      )
      parser.add_argument(
          """--checkpoint_path""", required=True, type=str, help="""Path to the original TensorFlow checkpoint (.ckpt file)."""
      )
      parser.add_argument(
          """--pytorch_dump_folder_path""", required=True, type=str, help="""Path to the output PyTorch model directory."""
      )
      parser.add_argument(
          """--push_to_hub""", action="""store_true""", help="""Whether or not to push the converted model to the 🤗 hub."""
      )

      _lowerCamelCase         =	parser.parse_args()
      convert_movilevit_checkpoint(
          args.model_name, args.checkpoint_path, args.pytorch_dump_folder_path, args.push_to_hub
      )






