



import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


__snake_case    :		Any  =logging.get_logger(__name__)

__snake_case    :		Optional[Any]  ={
    'Salesforce/blip-vqa-base': 'https://huggingface.co/Salesforce/blip-vqa-base/resolve/main/config.json',
    'Salesforce/blip-vqa-capfit-large': (
        'https://huggingface.co/Salesforce/blip-vqa-base-capfit/resolve/main/config.json'
    ),
    'Salesforce/blip-image-captioning-base': (
        'https://huggingface.co/Salesforce/blip-image-captioning-base/resolve/main/config.json'
    ),
    'Salesforce/blip-image-captioning-large': (
        'https://huggingface.co/Salesforce/blip-image-captioning-large/resolve/main/config.json'
    ),
    'Salesforce/blip-itm-base-coco': 'https://huggingface.co/Salesforce/blip-itm-base-coco/resolve/main/config.json',
    'Salesforce/blip-itm-large-coco': 'https://huggingface.co/Salesforce/blip-itm-large-coco/resolve/main/config.json',
    'Salesforce/blip-itm-base-flikr': 'https://huggingface.co/Salesforce/blip-itm-base-flikr/resolve/main/config.json',
    'Salesforce/blip-itm-large-flikr': (
        'https://huggingface.co/Salesforce/blip-itm-large-flikr/resolve/main/config.json'
    ),
}



class 	lowerCamelCase__      (							lowerCamelCase__):




		'''simple docstring'''



		snake_case_     ="""blip_text_model"""



		def __init__(self		,__lowerCamelCase=3_05_24		,__lowerCamelCase=7_68		,__lowerCamelCase=7_68		,__lowerCamelCase=30_72		,__lowerCamelCase=7_68		,__lowerCamelCase=12		,__lowerCamelCase=8		,__lowerCamelCase=5_12		,__lowerCamelCase="gelu"		,__lowerCamelCase=1e-12		,__lowerCamelCase=0.0		,__lowerCamelCase=0.0		,__lowerCamelCase=0.02		,__lowerCamelCase=3_05_22		,__lowerCamelCase=2		,__lowerCamelCase=0		,__lowerCamelCase=1_02		,__lowerCamelCase=True		,__lowerCamelCase=True		,**__lowerCamelCase		,)					->      Optional[Any]:

						"""simple docstring"""






						super().__init__(
						    pad_token_id=__lowerCamelCase		,bos_token_id=__lowerCamelCase		,eos_token_id=__lowerCamelCase		,sep_token_id=__lowerCamelCase		,**__lowerCamelCase		,)

						lowerCAmelCase__					:    Any												=					vocab_size
						lowerCAmelCase__					:    List[Any]												=					hidden_size
						lowerCAmelCase__					:    Optional[int]												=					encoder_hidden_size
						lowerCAmelCase__					:    Tuple												=					intermediate_size
						lowerCAmelCase__					:    Any												=					projection_dim
						lowerCAmelCase__					:    Optional[Any]												=					hidden_dropout_prob
						lowerCAmelCase__					:    Tuple												=					num_hidden_layers
						lowerCAmelCase__					:    Any												=					num_attention_heads
						lowerCAmelCase__					:    Optional[int]												=					max_position_embeddings
						lowerCAmelCase__					:    Optional[Any]												=					layer_norm_eps
						lowerCAmelCase__					:    Any												=					hidden_act
						lowerCAmelCase__					:    Optional[int]												=					initializer_range
						lowerCAmelCase__					:    Dict												=					attention_probs_dropout_prob
						lowerCAmelCase__					:    Dict												=					is_decoder
						lowerCAmelCase__					:    List[Any]												=					use_cache



		@classmethod
		def 		lowerCAmelCase__				(cls		,__lowerCamelCase		,**__lowerCamelCase			)					->      "PretrainedConfig":

						"""simple docstring"""






						cls._set_token_in_kwargs(__lowerCamelCase			)

						lowerCAmelCase__						,		lowerCAmelCase__					:    Dict												=					cls.get_config_dict(__lowerCamelCase		,**__lowerCamelCase			)

						# get the text config dict if we are loading from BlipConfig
						if config_dict.get('''model_type'''			) == "blip":
										lowerCAmelCase__					:    Tuple												=					config_dict['''text_config''']

						if "model_type" in config_dict and hasattr(cls		,'''model_type'''			) and config_dict["model_type"] != cls.model_type:
										logger.warning(
										    f"""You are using a model of type {config_dict['model_type']} to instantiate a model of type """
										    f"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""			)

						return cls.from_dict(__lowerCamelCase		,**__lowerCamelCase			)



class 	lowerCamelCase__      (							lowerCamelCase__):




		'''simple docstring'''



		snake_case_     ="""blip_vision_model"""



		def __init__(self		,__lowerCamelCase=7_68		,__lowerCamelCase=30_72		,__lowerCamelCase=5_12		,__lowerCamelCase=12		,__lowerCamelCase=12		,__lowerCamelCase=3_84		,__lowerCamelCase=16		,__lowerCamelCase="gelu"		,__lowerCamelCase=1e-5		,__lowerCamelCase=0.0		,__lowerCamelCase=1e-10		,**__lowerCamelCase		,)					->      Optional[Any]:

						"""simple docstring"""






						super().__init__(**__lowerCamelCase			)

						lowerCAmelCase__					:    str												=					hidden_size
						lowerCAmelCase__					:    List[Any]												=					intermediate_size
						lowerCAmelCase__					:    Optional[int]												=					projection_dim
						lowerCAmelCase__					:    Union[str, Any]												=					num_hidden_layers
						lowerCAmelCase__					:    Union[str, Any]												=					num_attention_heads
						lowerCAmelCase__					:    Optional[int]												=					patch_size
						lowerCAmelCase__					:    Tuple												=					image_size
						lowerCAmelCase__					:    Union[str, Any]												=					initializer_range
						lowerCAmelCase__					:    List[str]												=					attention_dropout
						lowerCAmelCase__					:    int												=					layer_norm_eps
						lowerCAmelCase__					:    Dict												=					hidden_act



		@classmethod
		def 		lowerCAmelCase__				(cls		,__lowerCamelCase		,**__lowerCamelCase			)					->      "PretrainedConfig":

						"""simple docstring"""






						cls._set_token_in_kwargs(__lowerCamelCase			)

						lowerCAmelCase__						,		lowerCAmelCase__					:    Any												=					cls.get_config_dict(__lowerCamelCase		,**__lowerCamelCase			)

						# get the vision config dict if we are loading from BlipConfig
						if config_dict.get('''model_type'''			) == "blip":
										lowerCAmelCase__					:    int												=					config_dict['''vision_config''']

						if "model_type" in config_dict and hasattr(cls		,'''model_type'''			) and config_dict["model_type"] != cls.model_type:
										logger.warning(
										    f"""You are using a model of type {config_dict['model_type']} to instantiate a model of type """
										    f"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""			)

						return cls.from_dict(__lowerCamelCase		,**__lowerCamelCase			)



class 	lowerCamelCase__      (							lowerCamelCase__):




		'''simple docstring'''



		snake_case_     ="""blip"""
		snake_case_     =True



		def __init__(self		,__lowerCamelCase=None		,__lowerCamelCase=None		,__lowerCamelCase=5_12		,__lowerCamelCase=2.6592		,__lowerCamelCase=2_56		,**__lowerCamelCase		,)					->      List[str]:

						"""simple docstring"""






						super().__init__(**__lowerCamelCase			)

						if text_config is None:
										lowerCAmelCase__					:    List[Any]												=					{}
										logger.info('''`text_config` is `None`. Initializing the `BlipTextConfig` with default values.'''			)

						if vision_config is None:
										lowerCAmelCase__					:    List[Any]												=					{}
										logger.info('''`vision_config` is `None`. Initializing the `BlipVisionConfig` with default values.'''			)

						lowerCAmelCase__					:    List[Any]												=					BlipTextConfig(**__lowerCamelCase			)
						lowerCAmelCase__					:    int												=					BlipVisionConfig(**__lowerCamelCase			)

						lowerCAmelCase__					:    Optional[int]												=					self.vision_config.hidden_size

						lowerCAmelCase__					:    Any												=					projection_dim
						lowerCAmelCase__					:    Dict												=					logit_scale_init_value
						lowerCAmelCase__					:    int												=					1.0
						lowerCAmelCase__					:    Tuple												=					0.02
						lowerCAmelCase__					:    Union[str, Any]												=					image_text_hidden_size



		@classmethod
		def 		lowerCAmelCase__				(cls		,__lowerCamelCase		,__lowerCamelCase		,**__lowerCamelCase			)					->      List[Any]:

						"""simple docstring"""






						return cls(text_config=text_config.to_dict()		,vision_config=vision_config.to_dict()		,**__lowerCamelCase			)



		def 		lowerCAmelCase__				(self			)					->      Dict:

						"""simple docstring"""






						lowerCAmelCase__					:    Tuple												=					copy.deepcopy(self.__dict__			)
						lowerCAmelCase__					:    int												=					self.text_config.to_dict()
						lowerCAmelCase__					:    Tuple												=					self.vision_config.to_dict()
						lowerCAmelCase__					:    List[Any]												=					self.__class__.model_type
						return output






import argparse
import json
from pathlib import Path

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

from transformers import (
    BertTokenizer,
    ViltConfig,
    ViltForImageAndTextRetrieval,
    ViltForImagesAndTextClassification,
    ViltForMaskedLM,
    ViltForQuestionAnswering,
    ViltImageProcessor,
    ViltProcessor,
)
from transformers.utils import logging


logging.set_verbosity_info()
__snake_case    :		Tuple  =logging.get_logger(__name__)






def      lowerCAmelCase__		(   lowerCamelCase_		:		Tuple	,lowerCamelCase_		:		Dict=False	,lowerCamelCase_		:		List[Any]=False	,lowerCamelCase_		:		int=False):





				'''simple docstring'''

				lowerCAmelCase__					:    Tuple												=					[]
				for i in range(config.num_hidden_layers):
								# encoder layers: output projection, 2 feedforward neural networks and 2 layernorms
								rename_keys.append((f"""transformer.blocks.{i}.norm1.weight""", f"""vilt.encoder.layer.{i}.layernorm_before.weight"""))
								rename_keys.append((f"""transformer.blocks.{i}.norm1.bias""", f"""vilt.encoder.layer.{i}.layernorm_before.bias"""))
								rename_keys.append(
								    (f"""transformer.blocks.{i}.attn.proj.weight""", f"""vilt.encoder.layer.{i}.attention.output.dense.weight"""))
								rename_keys.append(
								    (f"""transformer.blocks.{i}.attn.proj.bias""", f"""vilt.encoder.layer.{i}.attention.output.dense.bias"""))
								rename_keys.append((f"""transformer.blocks.{i}.norm2.weight""", f"""vilt.encoder.layer.{i}.layernorm_after.weight"""))
								rename_keys.append((f"""transformer.blocks.{i}.norm2.bias""", f"""vilt.encoder.layer.{i}.layernorm_after.bias"""))
								rename_keys.append(
								    (f"""transformer.blocks.{i}.mlp.fc1.weight""", f"""vilt.encoder.layer.{i}.intermediate.dense.weight"""))
								rename_keys.append((f"""transformer.blocks.{i}.mlp.fc1.bias""", f"""vilt.encoder.layer.{i}.intermediate.dense.bias"""))
								rename_keys.append((f"""transformer.blocks.{i}.mlp.fc2.weight""", f"""vilt.encoder.layer.{i}.output.dense.weight"""))
								rename_keys.append((f"""transformer.blocks.{i}.mlp.fc2.bias""", f"""vilt.encoder.layer.{i}.output.dense.bias"""))

				# embeddings
				rename_keys.extend(
				    [
				        # text embeddings
				        ('''text_embeddings.word_embeddings.weight''', '''vilt.embeddings.text_embeddings.word_embeddings.weight'''),
				        (
				            '''text_embeddings.position_embeddings.weight''',
				            '''vilt.embeddings.text_embeddings.position_embeddings.weight''',
				        ),
				        ('''text_embeddings.position_ids''', '''vilt.embeddings.text_embeddings.position_ids'''),
				        (
				            '''text_embeddings.token_type_embeddings.weight''',
				            '''vilt.embeddings.text_embeddings.token_type_embeddings.weight''',
				        ),
				        ('''text_embeddings.LayerNorm.weight''', '''vilt.embeddings.text_embeddings.LayerNorm.weight'''),
				        ('''text_embeddings.LayerNorm.bias''', '''vilt.embeddings.text_embeddings.LayerNorm.bias'''),
				        # patch embeddings
				        ('''transformer.cls_token''', '''vilt.embeddings.cls_token'''),
				        ('''transformer.patch_embed.proj.weight''', '''vilt.embeddings.patch_embeddings.projection.weight'''),
				        ('''transformer.patch_embed.proj.bias''', '''vilt.embeddings.patch_embeddings.projection.bias'''),
				        ('''transformer.pos_embed''', '''vilt.embeddings.position_embeddings'''),
				        # token type embeddings
				        ('''token_type_embeddings.weight''', '''vilt.embeddings.token_type_embeddings.weight'''),
				    ])

				# final layernorm + pooler
				rename_keys.extend(
				    [
				        ('''transformer.norm.weight''', '''vilt.layernorm.weight'''),
				        ('''transformer.norm.bias''', '''vilt.layernorm.bias'''),
				        ('''pooler.dense.weight''', '''vilt.pooler.dense.weight'''),
				        ('''pooler.dense.bias''', '''vilt.pooler.dense.bias'''),
				    ])

				# classifier head(s)
				if vqa_model:
								# classification head
								rename_keys.extend(
								    [
								        ('''vqa_classifier.0.weight''', '''classifier.0.weight'''),
								        ('''vqa_classifier.0.bias''', '''classifier.0.bias'''),
								        ('''vqa_classifier.1.weight''', '''classifier.1.weight'''),
								        ('''vqa_classifier.1.bias''', '''classifier.1.bias'''),
								        ('''vqa_classifier.3.weight''', '''classifier.3.weight'''),
								        ('''vqa_classifier.3.bias''', '''classifier.3.bias'''),
								    ])
				elif nlvr_model:
								# classification head
								rename_keys.extend(
								    [
								        ('''nlvr2_classifier.0.weight''', '''classifier.0.weight'''),
								        ('''nlvr2_classifier.0.bias''', '''classifier.0.bias'''),
								        ('''nlvr2_classifier.1.weight''', '''classifier.1.weight'''),
								        ('''nlvr2_classifier.1.bias''', '''classifier.1.bias'''),
								        ('''nlvr2_classifier.3.weight''', '''classifier.3.weight'''),
								        ('''nlvr2_classifier.3.bias''', '''classifier.3.bias'''),
								    ])
				else:
								pass

				return rename_keys






def      lowerCAmelCase__		(   lowerCamelCase_		:		Dict	,lowerCamelCase_		:		Optional[Any]):





				'''simple docstring'''

				for i in range(config.num_hidden_layers):
								lowerCAmelCase__					:    Optional[Any]												=					'''vilt.'''
								# read in weights + bias of input projection layer (in timm, this is a single matrix + bias)
								lowerCAmelCase__					:    Dict												=					state_dict.pop(f"""transformer.blocks.{i}.attn.qkv.weight""")
								lowerCAmelCase__					:    Tuple												=					state_dict.pop(f"""transformer.blocks.{i}.attn.qkv.bias""")
								# next, add query, keys and values (in that order) to the state dict
								lowerCAmelCase__					:    Dict												=					in_proj_weight[
								    : config.hidden_size, :
								]
								lowerCAmelCase__					:    Tuple												=					in_proj_bias[: config.hidden_size]
								lowerCAmelCase__					:    Union[str, Any]												=					in_proj_weight[
								    config.hidden_size : config.hidden_size * 2, :
								]
								lowerCAmelCase__					:    Optional[Any]												=					in_proj_bias[
								    config.hidden_size : config.hidden_size * 2
								]
								lowerCAmelCase__					:    str												=					in_proj_weight[
								    -config.hidden_size :, :
								]
								lowerCAmelCase__					:    Union[str, Any]												=					in_proj_bias[-config.hidden_size :]






def      lowerCAmelCase__		(   lowerCamelCase_		:		List[str]):





				'''simple docstring'''

				lowerCAmelCase__					:    List[Any]												=					['''head.weight''', '''head.bias''']
				for k in ignore_keys:
								state_dict.pop(lowerCamelCase_	,lowerCamelCase_)






def      lowerCAmelCase__		(   lowerCamelCase_		:		Optional[Any]	,lowerCamelCase_		:		Optional[int]	,lowerCamelCase_		:		int):





				'''simple docstring'''

				lowerCAmelCase__					:    int												=					dct.pop(lowerCamelCase_)
				lowerCAmelCase__					:    List[Any]												=					val






@torch.no_grad()
def      lowerCAmelCase__		(   lowerCamelCase_		:		int	,lowerCamelCase_		:		Union[str, Any]):





				'''simple docstring'''

				lowerCAmelCase__					:    Optional[int]												=					ViltConfig(image_size=384	,patch_size=32	,tie_word_embeddings=lowerCamelCase_)
				lowerCAmelCase__					:    Optional[Any]												=					False
				lowerCAmelCase__					:    Union[str, Any]												=					False
				lowerCAmelCase__					:    Dict												=					False
				lowerCAmelCase__					:    Any												=					False
				if "vqa" in checkpoint_url:
								lowerCAmelCase__					:    List[Any]												=					True
								lowerCAmelCase__					:    List[Any]												=					3129
								lowerCAmelCase__					:    List[Any]												=					'''huggingface/label-files'''
								lowerCAmelCase__					:    Union[str, Any]												=					'''vqa2-id2label.json'''
								lowerCAmelCase__					:    Optional[int]												=					json.load(open(hf_hub_download(lowerCamelCase_	,lowerCamelCase_	,repo_type='''dataset''')	,'''r'''))
								lowerCAmelCase__					:    Optional[Any]												=					{int(lowerCamelCase_): v for k, v in idalabel.items()}
								lowerCAmelCase__					:    Dict												=					idalabel
								lowerCAmelCase__					:    List[Any]												=					{v: k for k, v in idalabel.items()}
								lowerCAmelCase__					:    Optional[int]												=					ViltForQuestionAnswering(lowerCamelCase_)
				elif "nlvr" in checkpoint_url:
								lowerCAmelCase__					:    str												=					True
								lowerCAmelCase__					:    Optional[Any]												=					2
								lowerCAmelCase__					:    Optional[Any]												=					{0: '''False''', 1: '''True'''}
								lowerCAmelCase__					:    Union[str, Any]												=					{v: k for k, v in config.idalabel.items()}
								lowerCAmelCase__					:    int												=					3
								lowerCAmelCase__					:    int												=					ViltForImagesAndTextClassification(lowerCamelCase_)
				elif "irtr" in checkpoint_url:
								lowerCAmelCase__					:    str												=					True
								lowerCAmelCase__					:    List[str]												=					ViltForImageAndTextRetrieval(lowerCamelCase_)
				elif "mlm_itm" in checkpoint_url:
								lowerCAmelCase__					:    Any												=					True
								lowerCAmelCase__					:    int												=					ViltForMaskedLM(lowerCamelCase_)
				else:
								raise ValueError('''Unknown model type''')

				# load state_dict of original model, remove and rename some keys
				lowerCAmelCase__					:    Tuple												=					torch.hub.load_state_dict_from_url(lowerCamelCase_	,map_location='''cpu''')['''state_dict''']
				lowerCAmelCase__					:    Tuple												=					create_rename_keys(lowerCamelCase_	,lowerCamelCase_	,lowerCamelCase_	,lowerCamelCase_)
				for src, dest in rename_keys:
								rename_key(lowerCamelCase_	,lowerCamelCase_	,lowerCamelCase_)
				read_in_q_k_v(lowerCamelCase_	,lowerCamelCase_)
				if mlm_model or irtr_model:
								lowerCAmelCase__					:    int												=					['''itm_score.fc.weight''', '''itm_score.fc.bias''']
								for k in ignore_keys:
												state_dict.pop(lowerCamelCase_	,lowerCamelCase_)

    # load state dict into HuggingFace model
				model.eval()
				if mlm_model:
								lowerCAmelCase__						,		lowerCAmelCase__					:    str												=					model.load_state_dict(lowerCamelCase_	,strict=lowerCamelCase_)
								assert missing_keys == ["mlm_score.decoder.bias"]
				else:
								model.load_state_dict(lowerCamelCase_)

				# Define processor
				lowerCAmelCase__					:    List[str]												=					ViltImageProcessor(size=384)
				lowerCAmelCase__					:    Tuple												=					BertTokenizer.from_pretrained('''bert-base-uncased''')
				lowerCAmelCase__					:    Union[str, Any]												=					ViltProcessor(lowerCamelCase_	,lowerCamelCase_)

				# Forward pass on example inputs (image + text)
				if nlvr_model:
								lowerCAmelCase__					:    int												=					Image.open(requests.get('''https://lil.nlp.cornell.edu/nlvr/exs/ex0_0.jpg'''	,stream=lowerCamelCase_).raw)
								lowerCAmelCase__					:    Union[str, Any]												=					Image.open(requests.get('''https://lil.nlp.cornell.edu/nlvr/exs/ex0_0.jpg'''	,stream=lowerCamelCase_).raw)
								lowerCAmelCase__					:    Union[str, Any]												=					(
								    '''The left image contains twice the number of dogs as the right image, and at least two dogs in total are'''
								    ''' standing.'''
								)
								lowerCAmelCase__					:    Optional[int]												=					processor(lowerCamelCase_	,lowerCamelCase_	,return_tensors='''pt''')
								lowerCAmelCase__					:    Tuple												=					processor(lowerCamelCase_	,lowerCamelCase_	,return_tensors='''pt''')
								lowerCAmelCase__					:    Union[str, Any]												=					model(
								    input_ids=encoding_a.input_ids	,pixel_values=encoding_a.pixel_values	,pixel_values_a=encoding_a.pixel_values	,)
				else:
								lowerCAmelCase__					:    Dict												=					Image.open(requests.get('''http://images.cocodataset.org/val2017/000000039769.jpg'''	,stream=lowerCamelCase_).raw)
								if mlm_model:
												lowerCAmelCase__					:    int												=					'''a bunch of [MASK] laying on a [MASK].'''
								else:
												lowerCAmelCase__					:    Optional[int]												=					'''How many cats are there?'''
								lowerCAmelCase__					:    Optional[int]												=					processor(lowerCamelCase_	,lowerCamelCase_	,return_tensors='''pt''')
								lowerCAmelCase__					:    Any												=					model(**lowerCamelCase_)

				# Verify outputs
				if mlm_model:
								lowerCAmelCase__					:    Dict												=					torch.Size([1, 11, 30522])
								lowerCAmelCase__					:    int												=					torch.tensor([-12.5061, -12.5123, -12.5174])
								assert outputs.logits.shape == expected_shape
								assert torch.allclose(outputs.logits[0, 0, :3]	,lowerCamelCase_	,atol=1E-4)

								# verify masked token prediction equals "cats"
								lowerCAmelCase__					:    Optional[Any]												=					outputs.logits[0, 4, :].argmax(-1).item()
								assert tokenizer.decode([predicted_id]) == "cats"
				elif vqa_model:
								lowerCAmelCase__					:    List[Any]												=					torch.Size([1, 3129])
								lowerCAmelCase__					:    str												=					torch.tensor([-15.9495, -18.1472, -10.3041])
								assert torch.allclose(outputs.logits[0, :3]	,lowerCamelCase_	,atol=1E-4)
								assert outputs.logits.shape == expected_shape
								assert torch.allclose(outputs.logits[0, 0, :3]	,lowerCamelCase_	,atol=1E-4)

								# verify vqa prediction equals "2"
								lowerCAmelCase__					:    List[Any]												=					outputs.logits.argmax(-1).item()
								assert model.config.idalabel[predicted_idx] == "2"
				elif nlvr_model:
								lowerCAmelCase__					:    Union[str, Any]												=					torch.Size([1, 2])
								lowerCAmelCase__					:    Dict												=					torch.tensor([-2.8721, 2.1291])
								assert torch.allclose(outputs.logits[0, :3]	,lowerCamelCase_	,atol=1E-4)
								assert outputs.logits.shape == expected_shape

				Path(lowerCamelCase_).mkdir(exist_ok=lowerCamelCase_)
				print(f"""Saving model and processor to {pytorch_dump_folder_path}""")
				model.save_pretrained(lowerCamelCase_)
				processor.save_pretrained(lowerCamelCase_)


if __name__ == "__main__":
							__snake_case    :		Dict  =argparse.ArgumentParser()
							# Required parameters
							parser.add_argument(
							    '--checkpoint_url',
							    default='https://github.com/dandelin/ViLT/releases/download/200k/vilt_200k_mlm_itm.ckpt',
							    type=str,
							    help='URL of the checkpoint you\'d like to convert.',
							)
							parser.add_argument(
							    '--pytorch_dump_folder_path', default=None, type=str, help='Path to the output PyTorch model directory.'
							)

							__snake_case    :		Union[str, Any]  =parser.parse_args()
							convert_vilt_checkpoint(args.checkpoint_url, args.pytorch_dump_folder_path)

