



import argparse
import csv
import logging
import os
import random

import numpy as np
import torch
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset
from tqdm import tqdm, trange

from transformers import (
    CONFIG_NAME,
    WEIGHTS_NAME,
    AdamW,
    OpenAIGPTDoubleHeadsModel,
    OpenAIGPTTokenizer,
    get_linear_schedule_with_warmup,
)


logging.basicConfig(
    format='''%(asctime)s - %(levelname)s - %(name)s - %(message)s''', datefmt='''%m/%d/%Y %H:%M:%S''', level=logging.INFO
)
lowerCAmelCase__		:					Union[str, Any]							=logging.getLogger(__name__)






def      __lowercase       (			a__							,       a__       )    ->			Dict:
							__SCREAMING_SNAKE_CASE									= np.argmax(a__							,       axis=1       )
							return np.sum(outputs == labels       )






def      __lowercase       (			a__       )    ->			Optional[Any]:



							with open(a__							,       encoding='utf_8'       ) as f:
														__SCREAMING_SNAKE_CASE									= csv.reader(a__       )
														__SCREAMING_SNAKE_CASE									= []
														next(a__       )  # skip the first line
														for line in tqdm(a__       ):
																					output.append((' '.join(line[1:5]       ), line[5], line[6], int(line[-1]       ) - 1)       )
							return output






def      __lowercase       (			a__							,       a__							,       a__							,       a__							,       a__							,       a__       )    ->			int:
							__SCREAMING_SNAKE_CASE									= []
							for dataset in encoded_datasets:
														__SCREAMING_SNAKE_CASE									= len(a__       )
														__SCREAMING_SNAKE_CASE									= np.zeros((n_batch, 2, input_len)							,       dtype=np.intaa       )
														__SCREAMING_SNAKE_CASE									= np.zeros((n_batch, 2)							,       dtype=np.intaa       )
														__SCREAMING_SNAKE_CASE									= np.full((n_batch, 2, input_len)							,       fill_value=-1_00							,       dtype=np.intaa       )
														__SCREAMING_SNAKE_CASE									= np.zeros((n_batch,)							,       dtype=np.intaa       )
														for (
														    i,
														    (story, conta, conta, mc_label),
														) in enumerate(a__       ):
																					__SCREAMING_SNAKE_CASE									= [start_token] + story[:cap_length] + [delimiter_token] + conta[:cap_length] + [clf_token]
																					__SCREAMING_SNAKE_CASE									= [start_token] + story[:cap_length] + [delimiter_token] + conta[:cap_length] + [clf_token]
																					__SCREAMING_SNAKE_CASE									= with_conta
																					__SCREAMING_SNAKE_CASE									= with_conta
																					__SCREAMING_SNAKE_CASE									= len(a__       ) - 1
																					__SCREAMING_SNAKE_CASE									= len(a__       ) - 1
																					__SCREAMING_SNAKE_CASE									= with_conta
																					__SCREAMING_SNAKE_CASE									= with_conta
																					__SCREAMING_SNAKE_CASE									= mc_label
														__SCREAMING_SNAKE_CASE									= (input_ids, mc_token_ids, lm_labels, mc_labels)
														tensor_datasets.append(tuple(torch.tensor(a__       ) for t in all_inputs       )       )
							return tensor_datasets






def      __lowercase       (			)    ->			Dict:
							__SCREAMING_SNAKE_CASE									= argparse.ArgumentParser()
							parser.add_argument('--model_name'							,       type=a__							,       default='openai-gpt'							,       help='pretrained model name'       )
							parser.add_argument('--do_train'							,       action='store_true'							,       help='Whether to run training.'       )
							parser.add_argument('--do_eval'							,       action='store_true'							,       help='Whether to run eval on the dev set.'       )
							parser.add_argument(
							    '--output_dir'							,       default=a__							,       type=a__							,       required=a__							,       help='The output directory where the model predictions and checkpoints will be written.'							,       )
							parser.add_argument('--train_dataset'							,       type=a__							,       default=''       )
							parser.add_argument('--eval_dataset'							,       type=a__							,       default=''       )
							parser.add_argument('--seed'							,       type=a__							,       default=42       )
							parser.add_argument('--num_train_epochs'							,       type=a__							,       default=3       )
							parser.add_argument('--train_batch_size'							,       type=a__							,       default=8       )
							parser.add_argument('--eval_batch_size'							,       type=a__							,       default=16       )
							parser.add_argument('--adam_epsilon'							,       default=1E-8							,       type=a__							,       help='Epsilon for Adam optimizer.'       )
							parser.add_argument('--max_grad_norm'							,       type=a__							,       default=1       )
							parser.add_argument(
							    '--max_steps'							,       default=-1							,       type=a__							,       help=(
							        'If > 0: set total number of training                         steps to perform. Override num_train_epochs.'
							    )							,       )
							parser.add_argument(
							    '--gradient_accumulation_steps'							,       type=a__							,       default=1							,       help='Number of updates steps to accumulate before                        performing a backward/update pass.'							,       )
							parser.add_argument('--learning_rate'							,       type=a__							,       default=6.25E-5       )
							parser.add_argument('--warmup_steps'							,       default=0							,       type=a__							,       help='Linear warmup over warmup_steps.'       )
							parser.add_argument('--lr_schedule'							,       type=a__							,       default='warmup_linear'       )
							parser.add_argument('--weight_decay'							,       type=a__							,       default=0.01       )
							parser.add_argument('--lm_coef'							,       type=a__							,       default=0.9       )
							parser.add_argument('--n_valid'							,       type=a__							,       default=3_74       )

							parser.add_argument('--server_ip'							,       type=a__							,       default=''							,       help='Can be used for distant debugging.'       )
							parser.add_argument('--server_port'							,       type=a__							,       default=''							,       help='Can be used for distant debugging.'       )
							__SCREAMING_SNAKE_CASE									= parser.parse_args()
							print(a__       )

							if args.server_ip and args.server_port:
														# Distant debugging - see https://code.visualstudio.com/docs/python/debugging#_attach-to-a-local-script
														import ptvsd

														print('Waiting for debugger attach'       )
														ptvsd.enable_attach(address=(args.server_ip, args.server_port)							,       redirect_output=a__       )
														ptvsd.wait_for_attach()

							random.seed(args.seed       )
							np.random.seed(args.seed       )
							torch.manual_seed(args.seed       )
							torch.cuda.manual_seed_all(args.seed       )

							__SCREAMING_SNAKE_CASE									= torch.device('cuda' if torch.cuda.is_available() else 'cpu'       )
							__SCREAMING_SNAKE_CASE									= torch.cuda.device_count()
							logger.info('device: {}, n_gpu {}'.format(a__							,       a__       )       )

							if not args.do_train and not args.do_eval:
														raise ValueError('At least one of `do_train` or `do_eval` must be True.'       )

							if not os.path.exists(args.output_dir       ):
														os.makedirs(args.output_dir       )

							# Load tokenizer and model
							# This loading functions also add new tokens and embeddings called `special tokens`
							# These new embeddings will be fine-tuned on the RocStories dataset
							__SCREAMING_SNAKE_CASE									= ["""_start_""", """_delimiter_""", """_classify_"""]
							__SCREAMING_SNAKE_CASE									= OpenAIGPTTokenizer.from_pretrained(args.model_name       )
							tokenizer.add_tokens(a__       )
							__SCREAMING_SNAKE_CASE									= tokenizer.convert_tokens_to_ids(a__       )
							__SCREAMING_SNAKE_CASE									= OpenAIGPTDoubleHeadsModel.from_pretrained(args.model_name       )
							model.resize_token_embeddings(len(a__       )       )
							model.to(a__       )

							# Load and encode the datasets
							def tokenize_and_encode(a__       ):
														if isinstance(a__							,       a__       ):
																					return tokenizer.convert_tokens_to_ids(tokenizer.tokenize(a__       )       )
														elif isinstance(a__							,       a__       ):
																					return obj
														return [tokenize_and_encode(a__       ) for o in obj]

							logger.info('Encoding dataset...'       )
							__SCREAMING_SNAKE_CASE									= load_rocstories_dataset(args.train_dataset       )
							__SCREAMING_SNAKE_CASE									= load_rocstories_dataset(args.eval_dataset       )
							__SCREAMING_SNAKE_CASE									= (train_dataset, eval_dataset)
							__SCREAMING_SNAKE_CASE									= tokenize_and_encode(a__       )

							# Compute the max input length for the Transformer
							__SCREAMING_SNAKE_CASE									= model.config.n_positions // 2 - 2
							__SCREAMING_SNAKE_CASE									= max(
							    len(story[:max_length]       ) + max(len(conta[:max_length]       )							,       len(conta[:max_length]       )       ) + 3
							    for dataset in encoded_datasets
							    for story, conta, conta, _ in dataset       )
							__SCREAMING_SNAKE_CASE									= min(a__							,       model.config.n_positions       )  # Max size of input for the pre-trained model

							# Prepare inputs tensors and dataloaders
							__SCREAMING_SNAKE_CASE									= pre_process_datasets(a__							,       a__							,       a__							,       *a__       )
							__SCREAMING_SNAKE_CASE									= tensor_datasets[0], tensor_datasets[1]

							__SCREAMING_SNAKE_CASE									= TensorDataset(*a__       )
							__SCREAMING_SNAKE_CASE									= RandomSampler(a__       )
							__SCREAMING_SNAKE_CASE									= DataLoader(a__							,       sampler=a__							,       batch_size=args.train_batch_size       )

							__SCREAMING_SNAKE_CASE									= TensorDataset(*a__       )
							__SCREAMING_SNAKE_CASE									= SequentialSampler(a__       )
							__SCREAMING_SNAKE_CASE									= DataLoader(a__							,       sampler=a__							,       batch_size=args.eval_batch_size       )

							# Prepare optimizer
							if args.do_train:
														if args.max_steps > 0:
																					__SCREAMING_SNAKE_CASE									= args.max_steps
																					__SCREAMING_SNAKE_CASE									= args.max_steps // (len(a__       ) // args.gradient_accumulation_steps) + 1
														else:
																					__SCREAMING_SNAKE_CASE									= len(a__       ) // args.gradient_accumulation_steps * args.num_train_epochs

														__SCREAMING_SNAKE_CASE									= list(model.named_parameters()       )
														__SCREAMING_SNAKE_CASE									= ["""bias""", """LayerNorm.bias""", """LayerNorm.weight"""]
														__SCREAMING_SNAKE_CASE									= [
														    {
														        """params""": [p for n, p in param_optimizer if not any(nd in n for nd in no_decay       )],
														        """weight_decay""": args.weight_decay,
														    },
														    {"""params""": [p for n, p in param_optimizer if any(nd in n for nd in no_decay       )], """weight_decay""": 0.0},
														]
														__SCREAMING_SNAKE_CASE									= AdamW(a__							,       lr=args.learning_rate							,       eps=args.adam_epsilon       )
														__SCREAMING_SNAKE_CASE									= get_linear_schedule_with_warmup(
														    a__							,       num_warmup_steps=args.warmup_steps							,       num_training_steps=a__       )

							if args.do_train:
														__SCREAMING_SNAKE_CASE									= 0, 0, None
														model.train()
														for _ in trange(int(args.num_train_epochs       )							,       desc='Epoch'       ):
																					__SCREAMING_SNAKE_CASE									= 0
																					__SCREAMING_SNAKE_CASE									= 0
																					__SCREAMING_SNAKE_CASE									= tqdm(a__							,       desc='Training'       )
																					for step, batch in enumerate(a__       ):
																												__SCREAMING_SNAKE_CASE									= tuple(t.to(a__       ) for t in batch       )
																												__SCREAMING_SNAKE_CASE									= batch
																												__SCREAMING_SNAKE_CASE									= model(a__							,       mc_token_ids=a__							,       lm_labels=a__							,       mc_labels=a__       )
																												__SCREAMING_SNAKE_CASE									= args.lm_coef * losses[0] + losses[1]
																												loss.backward()
																												optimizer.step()
																												scheduler.step()
																												optimizer.zero_grad()
																												tr_loss += loss.item()
																												__SCREAMING_SNAKE_CASE									= (
																												    loss.item() if exp_average_loss is None else 0.7 * exp_average_loss + 0.3 * loss.item()
																												)
																												nb_tr_steps += 1
																												__SCREAMING_SNAKE_CASE									= """Training loss: {:.2e} lr: {:.2e}""".format(a__							,       scheduler.get_lr()[0]       )

    # Save a trained model
							if args.do_train:
														# Save a trained model, configuration and tokenizer
														__SCREAMING_SNAKE_CASE									= model.module if hasattr(a__							,       'module'       ) else model  # Only save the model itself

														# If we save using the predefined names, we can load using `from_pretrained`
														__SCREAMING_SNAKE_CASE									= os.path.join(args.output_dir							,       a__       )
														__SCREAMING_SNAKE_CASE									= os.path.join(args.output_dir							,       a__       )

														torch.save(model_to_save.state_dict()							,       a__       )
														model_to_save.config.to_json_file(a__       )
														tokenizer.save_vocabulary(args.output_dir       )

														# Load a trained model and vocabulary that you have fine-tuned
														__SCREAMING_SNAKE_CASE									= OpenAIGPTDoubleHeadsModel.from_pretrained(args.output_dir       )
														__SCREAMING_SNAKE_CASE									= OpenAIGPTTokenizer.from_pretrained(args.output_dir       )
														model.to(a__       )

							if args.do_eval:
														model.eval()
														__SCREAMING_SNAKE_CASE									= 0, 0
														__SCREAMING_SNAKE_CASE									= 0, 0
														for batch in tqdm(a__							,       desc='Evaluating'       ):
																					__SCREAMING_SNAKE_CASE									= tuple(t.to(a__       ) for t in batch       )
																					__SCREAMING_SNAKE_CASE									= batch
																					with torch.no_grad():
																												__SCREAMING_SNAKE_CASE									= model(
																												    a__							,       mc_token_ids=a__							,       lm_labels=a__							,       mc_labels=a__       )

																					__SCREAMING_SNAKE_CASE									= mc_logits.detach().cpu().numpy()
																					__SCREAMING_SNAKE_CASE									= mc_labels.to('cpu'       ).numpy()
																					__SCREAMING_SNAKE_CASE									= accuracy(a__							,       a__       )

																					eval_loss += mc_loss.mean().item()
																					eval_accuracy += tmp_eval_accuracy

																					nb_eval_examples += input_ids.size(0       )
																					nb_eval_steps += 1

														__SCREAMING_SNAKE_CASE									= eval_loss / nb_eval_steps
														__SCREAMING_SNAKE_CASE									= eval_accuracy / nb_eval_examples
														__SCREAMING_SNAKE_CASE									= tr_loss / nb_tr_steps if args.do_train else None
														__SCREAMING_SNAKE_CASE									= {"""eval_loss""": eval_loss, """eval_accuracy""": eval_accuracy, """train_loss""": train_loss}

														__SCREAMING_SNAKE_CASE									= os.path.join(args.output_dir							,       'eval_results.txt'       )
														with open(a__							,       'w'       ) as writer:
																					logger.info('***** Eval results *****'       )
																					for key in sorted(result.keys()       ):
																												logger.info('  %s = %s'							,       a__							,       str(result[key]       )       )
																												writer.write('%s = %s\n' % (key, str(result[key]       ))       )


if __name__ == "__main__":
			main()











import argparse
import json
from pathlib import Path

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

from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor
from transformers.utils import logging


logging.set_verbosity_info()
lowerCAmelCase__		:					Optional[int]							=logging.get_logger(__name__)






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

							# projection layer + position embeddings
							rename_keys.extend(
							    [
							        ('cls_token', 'deit.embeddings.cls_token'),
							        ('dist_token', 'deit.embeddings.distillation_token'),
							        ('patch_embed.proj.weight', 'deit.embeddings.patch_embeddings.projection.weight'),
							        ('patch_embed.proj.bias', 'deit.embeddings.patch_embeddings.projection.bias'),
							        ('pos_embed', 'deit.embeddings.position_embeddings'),
							    ]       )

							if base_model:
														# layernorm + pooler
														rename_keys.extend(
														    [
														        ('norm.weight', 'layernorm.weight'),
														        ('norm.bias', 'layernorm.bias'),
														        ('pre_logits.fc.weight', 'pooler.dense.weight'),
														        ('pre_logits.fc.bias', 'pooler.dense.bias'),
														    ]       )

														# if just the base model, we should remove "deit" from all keys that start with "deit"
														__SCREAMING_SNAKE_CASE									= [(pair[0], pair[1][4:]) if pair[1].startswith('deit'       ) else pair for pair in rename_keys]
							else:
														# layernorm + classification heads
														rename_keys.extend(
														    [
														        ('norm.weight', 'deit.layernorm.weight'),
														        ('norm.bias', 'deit.layernorm.bias'),
														        ('head.weight', 'cls_classifier.weight'),
														        ('head.bias', 'cls_classifier.bias'),
														        ('head_dist.weight', 'distillation_classifier.weight'),
														        ('head_dist.bias', 'distillation_classifier.bias'),
														    ]       )

							return rename_keys






def      __lowercase       (			a__							,       a__							,       a__=False       )    ->			Tuple:
							for i in range(config.num_hidden_layers       ):
														if base_model:
																					__SCREAMING_SNAKE_CASE									= ''
														else:
																					__SCREAMING_SNAKE_CASE									= 'deit.'
														# read in weights + bias of input projection layer (in timm, this is a single matrix + bias)
														__SCREAMING_SNAKE_CASE									= state_dict.pop(f"""blocks.{i}.attn.qkv.weight"""       )
														__SCREAMING_SNAKE_CASE									= state_dict.pop(f"""blocks.{i}.attn.qkv.bias"""       )
														# next, add query, keys and values (in that order) to the state dict
														__SCREAMING_SNAKE_CASE									= in_proj_weight[
														    : config.hidden_size, :
														]
														__SCREAMING_SNAKE_CASE									= in_proj_bias[: config.hidden_size]
														__SCREAMING_SNAKE_CASE									= in_proj_weight[
														    config.hidden_size : config.hidden_size * 2, :
														]
														__SCREAMING_SNAKE_CASE									= in_proj_bias[
														    config.hidden_size : config.hidden_size * 2
														]
														__SCREAMING_SNAKE_CASE									= in_proj_weight[
														    -config.hidden_size :, :
														]
														__SCREAMING_SNAKE_CASE									= in_proj_bias[-config.hidden_size :]






def      __lowercase       (			a__							,       a__							,       a__       )    ->			str:
							__SCREAMING_SNAKE_CASE									= dct.pop(a__       )
							__SCREAMING_SNAKE_CASE									= val






def      __lowercase       (			)    ->			List[Any]:
							__SCREAMING_SNAKE_CASE									= 'http://images.cocodataset.org/val2017/000000039769.jpg'
							__SCREAMING_SNAKE_CASE									= Image.open(requests.get(a__							,       stream=a__       ).raw       )
							return im






@torch.no_grad()
def      __lowercase       (			a__							,       a__       )    ->			Dict:
							__SCREAMING_SNAKE_CASE									= DeiTConfig()
							# all deit models have fine-tuned heads
							__SCREAMING_SNAKE_CASE									= False
							# dataset (fine-tuned on ImageNet 2012), patch_size and image_size
							__SCREAMING_SNAKE_CASE									= 10_00
							__SCREAMING_SNAKE_CASE									= 'huggingface/label-files'
							__SCREAMING_SNAKE_CASE									= 'imagenet-1k-id2label.json'
							__SCREAMING_SNAKE_CASE									= json.load(open(hf_hub_download(a__							,       a__							,       repo_type='dataset'       )							,       'r'       )       )
							__SCREAMING_SNAKE_CASE									= {int(a__       ): v for k, v in idalabel.items()}
							__SCREAMING_SNAKE_CASE									= idalabel
							__SCREAMING_SNAKE_CASE									= {v: k for k, v in idalabel.items()}
							__SCREAMING_SNAKE_CASE									= int(deit_name[-6:-4]       )
							__SCREAMING_SNAKE_CASE									= int(deit_name[-3:]       )
							# size of the architecture
							if deit_name[9:].startswith('tiny'       ):
														__SCREAMING_SNAKE_CASE									= 1_92
														__SCREAMING_SNAKE_CASE									= 7_68
														__SCREAMING_SNAKE_CASE									= 12
														__SCREAMING_SNAKE_CASE									= 3
							elif deit_name[9:].startswith('small'       ):
														__SCREAMING_SNAKE_CASE									= 3_84
														__SCREAMING_SNAKE_CASE									= 15_36
														__SCREAMING_SNAKE_CASE									= 12
														__SCREAMING_SNAKE_CASE									= 6
							if deit_name[9:].startswith('base'       ):
														pass
							elif deit_name[4:].startswith('large'       ):
														__SCREAMING_SNAKE_CASE									= 10_24
														__SCREAMING_SNAKE_CASE									= 40_96
														__SCREAMING_SNAKE_CASE									= 24
														__SCREAMING_SNAKE_CASE									= 16

							# load original model from timm
							__SCREAMING_SNAKE_CASE									= timm.create_model(a__							,       pretrained=a__       )
							timm_model.eval()

							# load state_dict of original model, remove and rename some keys
							__SCREAMING_SNAKE_CASE									= timm_model.state_dict()
							__SCREAMING_SNAKE_CASE									= create_rename_keys(a__							,       a__       )
							for src, dest in rename_keys:
														rename_key(a__							,       a__							,       a__       )
							read_in_q_k_v(a__							,       a__							,       a__       )

							# load HuggingFace model
							__SCREAMING_SNAKE_CASE									= DeiTForImageClassificationWithTeacher(a__       ).eval()
							model.load_state_dict(a__       )

							# Check outputs on an image, prepared by DeiTImageProcessor
							__SCREAMING_SNAKE_CASE									= int(
							    (2_56 / 2_24) * config.image_size       )  # to maintain same ratio w.r.t. 224 images, see https://github.com/facebookresearch/deit/blob/ab5715372db8c6cad5740714b2216d55aeae052e/datasets.py#L103
							__SCREAMING_SNAKE_CASE									= DeiTImageProcessor(size=a__							,       crop_size=config.image_size       )
							__SCREAMING_SNAKE_CASE									= image_processor(images=prepare_img()							,       return_tensors='pt'       )
							__SCREAMING_SNAKE_CASE									= encoding['pixel_values']
							__SCREAMING_SNAKE_CASE									= model(a__       )

							__SCREAMING_SNAKE_CASE									= timm_model(a__       )
							assert timm_logits.shape == outputs.logits.shape
							assert torch.allclose(a__							,       outputs.logits							,       atol=1E-3       )

							Path(a__       ).mkdir(exist_ok=a__       )
							print(f"""Saving model {deit_name} to {pytorch_dump_folder_path}"""       )
							model.save_pretrained(a__       )
							print(f"""Saving image processor to {pytorch_dump_folder_path}"""       )
							image_processor.save_pretrained(a__       )


if __name__ == "__main__":
			lowerCAmelCase__		:					Union[str, Any]							=argparse.ArgumentParser()
			# Required parameters
			parser.add_argument(
			    '''--deit_name''',
			    default='''vit_deit_base_distilled_patch16_224''',
			    type=str,
			    help='''Name of the DeiT timm model you\'d like to convert.''',
			)
			parser.add_argument(
			    '''--pytorch_dump_folder_path''', default=None, type=str, help='''Path to the output PyTorch model directory.'''
			)

			lowerCAmelCase__		:					str							=parser.parse_args()
			convert_deit_checkpoint(args.deit_name, args.pytorch_dump_folder_path)






