
"""simple docstring"""





import json
import logging
import os
import re
import sys
from dataclasses import dataclass, field
from typing import Any, Dict, List, Optional, Union

import datasets
import numpy as np
import torch
import torchaudio
from packaging import version
from torch import nn

import transformers
from transformers import (
    HfArgumentParser,
    Trainer,
    TrainingArguments,
    WavaVecaCTCTokenizer,
    WavaVecaFeatureExtractor,
    WavaVecaForCTC,
    WavaVecaProcessor,
    is_apex_available,
    set_seed,
)
from transformers.trainer_utils import get_last_checkpoint, is_main_process


if is_apex_available():
				from apex import amp


if version.parse(version.parse(torch.__version__).base_version) >= version.parse("""1.6"""):
				_a														=		True
				from torch.cuda.amp import autocast

_a														=		logging.getLogger(__name__)



def       lowerCamelCase__		(			__snake_case=None,     __snake_case=None	)							->		List[str]:


					"""simple docstring"""





					return field(default_factory=lambda: default,     metadata=__snake_case	)






@dataclass
class     _UpperCAmelCase:
		lowercase__						=      field(
		    metadata={'help': 'Path to pretrained model or model identifier from huggingface.co/models'}	)
		lowercase__						=      field(
		    default=lowerCamelCase      ,     metadata={'help': 'Where do you want to store the pretrained models downloaded from huggingface.co'}      ,     )
		lowercase__						=      field(
		    default=lowerCamelCase      ,     metadata={'help': 'Whether to freeze the feature extractor layers of the model.'}	)
		lowercase__						=      field(
		    default=0.1      ,     metadata={'help': 'The dropout ratio for the attention probabilities.'}	)
		lowercase__						=      field(
		    default=0.1      ,     metadata={'help': 'The dropout ratio for activations inside the fully connected layer.'}	)
		lowercase__						=      field(
		    default=0.1      ,     metadata={
		        'help': 'The dropout probabilitiy for all fully connected layers in the embeddings, encoder, and pooler.'
		    }      ,     )
		lowercase__						=      field(
		    default=0.1      ,     metadata={'help': 'The dropout probabilitiy for all 1D convolutional layers in feature extractor.'}      ,     )
		lowercase__						=      field(
		    default=0.05      ,     metadata={
		        'help': (
		            'Propability of each feature vector along the time axis to be chosen as the start of the vector'
		            'span to be masked. Approximately ``mask_time_prob * sequence_length // mask_time_length`` feature'
		            'vectors will be masked along the time axis. This is only relevant if ``apply_spec_augment is True``.'
		        )
		    }      ,     )
		lowercase__						=      field(default=0.0      ,     metadata={'help': 'The LayerDrop probability.'}	)






@dataclass
class     _UpperCAmelCase:
		lowercase__						=      field(
		    default=lowerCamelCase      ,     metadata={'help': 'The configuration name of the dataset to use (via the datasets library).'}	)
		lowercase__						=      field(
		    default='train+validation'      ,     metadata={
		        'help': 'The name of the training data set split to use (via the datasets library). Defaults to \'train\''
		    }      ,     )
		lowercase__						=      field(
		    default=lowerCamelCase      ,     metadata={'help': 'Overwrite the cached preprocessed datasets or not.'}	)
		lowercase__						=      field(
		    default=lowerCamelCase      ,     metadata={'help': 'The number of processes to use for the preprocessing.'}      ,     )
		lowercase__						=      field(
		    default=lowerCamelCase      ,     metadata={
		        'help': (
		            'For debugging purposes or quicker training, truncate the number of training examples to this '
		            'value if set.'
		        )
		    }      ,     )
		lowercase__						=      field(
		    default=lowerCamelCase      ,     metadata={
		        'help': (
		            'For debugging purposes or quicker training, truncate the number of validation examples to this '
		            'value if set.'
		        )
		    }      ,     )
		lowercase__						=      list_field(
		    default=[',', '?', '.', '!', '-', ';', ':', '""', '%', '\'', '"', '�']      ,     metadata={'help': 'A list of characters to remove from the transcripts.'}      ,     )






@dataclass
class     _UpperCAmelCase:
		lowercase__						=      42
		lowercase__						=      True
		lowercase__						=      None
		lowercase__						=      None
		lowercase__						=      None
		lowercase__						=      None



		def __call__(					self				,		__a)       ->       Dict[str, torch.Tensor]:






							'''simple docstring'''
							# split inputs and labels since they have to be of different lenghts and need
							# different padding methods
							_UpperCamelCase							 =  [{'''input_values''': feature['''input_values''']} for feature in features]
							_UpperCamelCase							 =  [{'''input_ids''': feature['''labels''']} for feature in features]

							_UpperCamelCase							 =  self.processor.pad(
							    __a				,		padding=self.padding				,		max_length=self.max_length				,		pad_to_multiple_of=self.pad_to_multiple_of				,		return_tensors='''pt'''				,		)
							_UpperCamelCase							 =  self.processor.pad(
							    labels=__a				,		padding=self.padding				,		max_length=self.max_length_labels				,		pad_to_multiple_of=self.pad_to_multiple_of_labels				,		return_tensors='''pt'''				,		)

							# replace padding with -100 to ignore loss correctly
							_UpperCamelCase							 =  labels_batch['''input_ids'''].masked_fill(labels_batch.attention_mask.ne(1)				,		-1_00)

							_UpperCamelCase							 =  labels

							return batch






class     _UpperCAmelCase(    lowerCamelCase	):



		def 						UpperCAmelCase							(					self				,		__a				,		__a)       ->       torch.Tensor:






							'''simple docstring'''
							model.train()
							_UpperCamelCase							 =  self._prepare_inputs(__a)

							if self.use_amp:
												with autocast():
																	_UpperCamelCase							 =  self.compute_loss(__a				,		__a)
							else:
												_UpperCamelCase							 =  self.compute_loss(__a				,		__a)

							if self.args.n_gpu > 1:
												if model.module.config.ctc_loss_reduction == "mean":
																	_UpperCamelCase							 =  loss.mean()
												elif model.module.config.ctc_loss_reduction == "sum":
																	_UpperCamelCase							 =  loss.sum() / (inputs['''labels'''] >= 0).sum()
												else:
																	raise ValueError(F'''{model.config.ctc_loss_reduction} is not valid. Choose one of [\'mean\', \'sum\']''')

							if self.args.gradient_accumulation_steps > 1:
												_UpperCamelCase							 =  loss / self.args.gradient_accumulation_steps

							if self.use_amp:
												self.scaler.scale(__a).backward()
							elif self.use_apex:
												with amp.scale_loss(__a				,		self.optimizer) as scaled_loss:
																	scaled_loss.backward()
							elif self.deepspeed:
												self.deepspeed.backward(__a)
							else:
												loss.backward()

							return loss.detach()





def       lowerCamelCase__		(			)							->		List[str]:


					"""simple docstring"""





					_UpperCamelCase							 =  HfArgumentParser((ModelArguments, DataTrainingArguments, TrainingArguments)	)
					if len(sys.argv	) == 2 and sys.argv[1].endswith('''.json'''	):
										# If we pass only one argument to the script and it's the path to a json file,
										# let's parse it to get our arguments.
										_UpperCamelCase ,  _UpperCamelCase ,  _UpperCamelCase							 =  parser.parse_json_file(json_file=os.path.abspath(sys.argv[1]	)	)
					else:
										_UpperCamelCase ,  _UpperCamelCase ,  _UpperCamelCase							 =  parser.parse_args_into_dataclasses()

					# Detecting last checkpoint.
					_UpperCamelCase							 =  None
					if os.path.isdir(training_args.output_dir	) and training_args.do_train and not training_args.overwrite_output_dir:
										_UpperCamelCase							 =  get_last_checkpoint(training_args.output_dir	)
										if last_checkpoint is None and len(os.listdir(training_args.output_dir	)	) > 0:
															raise ValueError(
															    F'''Output directory ({training_args.output_dir}) already exists and is not empty. '''
															    '''Use --overwrite_output_dir to overcome.'''	)
										elif last_checkpoint is not None:
															logger.info(
															    F'''Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change '''
															    '''the `--output_dir` or add `--overwrite_output_dir` to train from scratch.'''	)

    # Setup logging
					logging.basicConfig(
					    format='''%(asctime)s - %(levelname)s - %(name)s - %(message)s''',     datefmt='''%m/%d/%Y %H:%M:%S''',     handlers=[logging.StreamHandler(sys.stdout	)],     )
					logger.setLevel(logging.INFO if is_main_process(training_args.local_rank	) else logging.WARN	)

					# Log on each process the small summary:
					logger.warning(
					    F'''Process rank: {training_args.local_rank}, device: {training_args.device}, n_gpu: {training_args.n_gpu}'''
					    + F'''distributed training: {bool(training_args.local_rank != -1	)}, 16-bits training: {training_args.fpaa}'''	)
					# Set the verbosity to info of the Transformers logger (on main process only):
					if is_main_process(training_args.local_rank	):
										transformers.utils.logging.set_verbosity_info()
					logger.info('''Training/evaluation parameters %s''',     __snake_case	)

					# Set seed before initializing model.
					set_seed(training_args.seed	)

					# Get the datasets:
					_UpperCamelCase							 =  datasets.load_dataset(
					    '''common_voice''',     data_args.dataset_config_name,     split=data_args.train_split_name	)
					_UpperCamelCase							 =  datasets.load_dataset('''common_voice''',     data_args.dataset_config_name,     split='''test'''	)

					# Create and save tokenizer
					_UpperCamelCase							 =  F'''[{"".join(data_args.chars_to_ignore	)}]'''

					def remove_special_characters(__snake_case	):
										_UpperCamelCase							 =  re.sub(__snake_case,     '''''',     batch['''sentence''']	).lower() + ''' '''
										return batch

					_UpperCamelCase							 =  train_dataset.map(__snake_case,     remove_columns=['''sentence''']	)
					_UpperCamelCase							 =  eval_dataset.map(__snake_case,     remove_columns=['''sentence''']	)

					def extract_all_chars(__snake_case	):
										_UpperCamelCase							 =  ''' '''.join(batch['''text''']	)
										_UpperCamelCase							 =  list(set(__snake_case	)	)
										return {"vocab": [vocab], "all_text": [all_text]}

					_UpperCamelCase							 =  train_dataset.map(
					    __snake_case,     batched=__snake_case,     batch_size=-1,     keep_in_memory=__snake_case,     remove_columns=train_dataset.column_names,     )
					_UpperCamelCase							 =  train_dataset.map(
					    __snake_case,     batched=__snake_case,     batch_size=-1,     keep_in_memory=__snake_case,     remove_columns=eval_dataset.column_names,     )

					_UpperCamelCase							 =  list(set(vocab_train['''vocab'''][0]	) | set(vocab_test['''vocab'''][0]	)	)
					_UpperCamelCase							 =  {v: k for k, v in enumerate(__snake_case	)}
					_UpperCamelCase							 =  vocab_dict[''' ''']
					del vocab_dict[" "]
					_UpperCamelCase							 =  len(__snake_case	)
					_UpperCamelCase							 =  len(__snake_case	)

					with open('''vocab.json''',     '''w'''	) as vocab_file:
										json.dump(__snake_case,     __snake_case	)

					# Load pretrained model and tokenizer
					#
					# Distributed training:
					# The .from_pretrained methods guarantee that only one local process can concurrently
					# download model & vocab.
					_UpperCamelCase							 =  WavaVecaCTCTokenizer(
					    '''vocab.json''',     unk_token='''[UNK]''',     pad_token='''[PAD]''',     word_delimiter_token='''|''',     )
					_UpperCamelCase							 =  WavaVecaFeatureExtractor(
					    feature_size=1,     sampling_rate=1_60_00,     padding_value=0.0,     do_normalize=__snake_case,     return_attention_mask=__snake_case	)
					_UpperCamelCase							 =  WavaVecaProcessor(feature_extractor=__snake_case,     tokenizer=__snake_case	)
					_UpperCamelCase							 =  WavaVecaForCTC.from_pretrained(
					    model_args.model_name_or_path,     cache_dir=model_args.cache_dir,     activation_dropout=model_args.activation_dropout,     attention_dropout=model_args.attention_dropout,     hidden_dropout=model_args.hidden_dropout,     feat_proj_dropout=model_args.feat_proj_dropout,     mask_time_prob=model_args.mask_time_prob,     gradient_checkpointing=training_args.gradient_checkpointing,     layerdrop=model_args.layerdrop,     ctc_loss_reduction='''mean''',     pad_token_id=processor.tokenizer.pad_token_id,     vocab_size=len(processor.tokenizer	),     )

					if data_args.max_train_samples is not None:
										_UpperCamelCase							 =  min(len(__snake_case	),     data_args.max_train_samples	)
										_UpperCamelCase							 =  train_dataset.select(range(__snake_case	)	)

					if data_args.max_val_samples is not None:
										_UpperCamelCase							 =  eval_dataset.select(range(data_args.max_val_samples	)	)

					_UpperCamelCase							 =  torchaudio.transforms.Resample(4_80_00,     1_60_00	)

					# Preprocessing the datasets.
					# We need to read the aduio files as arrays and tokenize the targets.
					def speech_file_to_array_fn(__snake_case	):
										_UpperCamelCase ,  _UpperCamelCase							 =  torchaudio.load(batch['''path''']	)
										_UpperCamelCase							 =  resampler(__snake_case	).squeeze().numpy()
										_UpperCamelCase							 =  1_60_00
										_UpperCamelCase							 =  batch['''text''']
										return batch

					_UpperCamelCase							 =  train_dataset.map(
					    __snake_case,     remove_columns=train_dataset.column_names,     num_proc=data_args.preprocessing_num_workers,     )
					_UpperCamelCase							 =  eval_dataset.map(
					    __snake_case,     remove_columns=eval_dataset.column_names,     num_proc=data_args.preprocessing_num_workers,     )

					def prepare_dataset(__snake_case	):
										# check that all files have the correct sampling rate
										assert (
										    len(set(batch['''sampling_rate''']	)	) == 1
										), F'''Make sure all inputs have the same sampling rate of {processor.feature_extractor.sampling_rate}.'''

										_UpperCamelCase							 =  processor(
										    audio=batch['''speech'''],     text=batch['''target_text'''],     sampling_rate=batch['''sampling_rate'''][0]	)
										batch.update(__snake_case	)
										return batch

					_UpperCamelCase							 =  train_dataset.map(
					    __snake_case,     remove_columns=train_dataset.column_names,     batch_size=training_args.per_device_train_batch_size,     batched=__snake_case,     num_proc=data_args.preprocessing_num_workers,     )
					_UpperCamelCase							 =  eval_dataset.map(
					    __snake_case,     remove_columns=eval_dataset.column_names,     batch_size=training_args.per_device_train_batch_size,     batched=__snake_case,     num_proc=data_args.preprocessing_num_workers,     )

					# Metric
					_UpperCamelCase							 =  datasets.load_metric('''wer'''	)

					def compute_metrics(__snake_case	):
										_UpperCamelCase							 =  pred.predictions
										_UpperCamelCase							 =  np.argmax(__snake_case,     axis=-1	)

										_UpperCamelCase							 =  processor.tokenizer.pad_token_id

										_UpperCamelCase							 =  processor.batch_decode(__snake_case	)
										# we do not want to group tokens when computing the metrics
										_UpperCamelCase							 =  processor.batch_decode(pred.label_ids,     group_tokens=__snake_case	)

										_UpperCamelCase							 =  wer_metric.compute(predictions=__snake_case,     references=__snake_case	)

										return {"wer": wer}

					if model_args.freeze_feature_extractor:
										model.freeze_feature_extractor()

					# Data collator
					_UpperCamelCase							 =  DataCollatorCTCWithPadding(processor=__snake_case,     padding=__snake_case	)

					# Initialize our Trainer
					_UpperCamelCase							 =  CTCTrainer(
					    model=__snake_case,     data_collator=__snake_case,     args=__snake_case,     compute_metrics=__snake_case,     train_dataset=train_dataset if training_args.do_train else None,     eval_dataset=eval_dataset if training_args.do_eval else None,     tokenizer=processor.feature_extractor,     )

					# Training
					if training_args.do_train:
										if last_checkpoint is not None:
															_UpperCamelCase							 =  last_checkpoint
										elif os.path.isdir(model_args.model_name_or_path	):
															_UpperCamelCase							 =  model_args.model_name_or_path
										else:
															_UpperCamelCase							 =  None

										# Save the feature_extractor and the tokenizer
										if is_main_process(training_args.local_rank	):
															processor.save_pretrained(training_args.output_dir	)

										_UpperCamelCase							 =  trainer.train(resume_from_checkpoint=__snake_case	)
										trainer.save_model()

										_UpperCamelCase							 =  train_result.metrics
										_UpperCamelCase							 =  (
										    data_args.max_train_samples if data_args.max_train_samples is not None else len(__snake_case	)
										)
										_UpperCamelCase							 =  min(__snake_case,     len(__snake_case	)	)

										trainer.log_metrics('''train''',     __snake_case	)
										trainer.save_metrics('''train''',     __snake_case	)
										trainer.save_state()

					# Evaluation
					_UpperCamelCase							 =  {}
					if training_args.do_eval:
										logger.info('''*** Evaluate ***'''	)
										_UpperCamelCase							 =  trainer.evaluate()
										_UpperCamelCase							 =  data_args.max_val_samples if data_args.max_val_samples is not None else len(__snake_case	)
										_UpperCamelCase							 =  min(__snake_case,     len(__snake_case	)	)

										trainer.log_metrics('''eval''',     __snake_case	)
										trainer.save_metrics('''eval''',     __snake_case	)

					return results


if __name__ == "__main__":
				main()








"""simple docstring"""





import argparse
import json
import os

import torch

from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer
from transformers.tokenization_utils_base import AddedToken



@torch.no_grad()
def       lowerCamelCase__		(			__snake_case,     __snake_case,     __snake_case,     __snake_case,     __snake_case	)							->		str:


					"""simple docstring"""





					with open(__snake_case	) as metadata_file:
										_UpperCamelCase							 =  json.load(__snake_case	)
					_UpperCamelCase							 =  LukeConfig(use_entity_aware_attention=__snake_case,     **metadata['''model_config''']	)

					# Load in the weights from the checkpoint_path
					_UpperCamelCase							 =  torch.load(__snake_case,     map_location='''cpu'''	)

					# Load the entity vocab file
					_UpperCamelCase							 =  load_entity_vocab(__snake_case	)

					_UpperCamelCase							 =  RobertaTokenizer.from_pretrained(metadata['''model_config''']['''bert_model_name''']	)

					# Add special tokens to the token vocabulary for downstream tasks
					_UpperCamelCase							 =  AddedToken('''<ent>''',     lstrip=__snake_case,     rstrip=__snake_case	)
					_UpperCamelCase							 =  AddedToken('''<ent2>''',     lstrip=__snake_case,     rstrip=__snake_case	)
					tokenizer.add_special_tokens({'''additional_special_tokens''': [entity_token_a, entity_token_a]}	)
					config.vocab_size += 2

					print(F'''Saving tokenizer to {pytorch_dump_folder_path}'''	)
					tokenizer.save_pretrained(__snake_case	)
					with open(os.path.join(__snake_case,     LukeTokenizer.vocab_files_names['''entity_vocab_file''']	),     '''w'''	) as f:
										json.dump(__snake_case,     __snake_case	)

					_UpperCamelCase							 =  LukeTokenizer.from_pretrained(__snake_case	)

					# Initialize the embeddings of the special tokens
					_UpperCamelCase							 =  state_dict['''embeddings.word_embeddings.weight''']
					_UpperCamelCase							 =  word_emb[tokenizer.convert_tokens_to_ids(['''@''']	)[0]].unsqueeze(0	)
					_UpperCamelCase							 =  word_emb[tokenizer.convert_tokens_to_ids(['''#''']	)[0]].unsqueeze(0	)
					_UpperCamelCase							 =  torch.cat([word_emb, ent_emb, enta_emb]	)

					# Initialize the query layers of the entity-aware self-attention mechanism
					for layer_index in range(config.num_hidden_layers	):
										for matrix_name in ["query.weight", "query.bias"]:
															_UpperCamelCase							 =  F'''encoder.layer.{layer_index}.attention.self.'''
															_UpperCamelCase							 =  state_dict[prefix + matrix_name]
															_UpperCamelCase							 =  state_dict[prefix + matrix_name]
															_UpperCamelCase							 =  state_dict[prefix + matrix_name]

    # Initialize the embedding of the [MASK2] entity using that of the [MASK] entity for downstream tasks
					_UpperCamelCase							 =  state_dict['''entity_embeddings.entity_embeddings.weight''']
					_UpperCamelCase							 =  entity_emb[entity_vocab['''[MASK]''']]

					_UpperCamelCase							 =  LukeModel(config=__snake_case	).eval()

					_UpperCamelCase ,  _UpperCamelCase							 =  model.load_state_dict(__snake_case,     strict=__snake_case	)
					if not (len(__snake_case	) == 1 and missing_keys[0] == "embeddings.position_ids"):
										raise ValueError(F'''Missing keys {", ".join(__snake_case	)}. Expected only missing embeddings.position_ids'''	)
					if not (all(key.startswith('''entity_predictions'''	) or key.startswith('''lm_head'''	) for key in unexpected_keys	)):
										raise ValueError(
										    '''Unexpected keys'''
										    F''' {", ".join([key for key in unexpected_keys if not (key.startswith("entity_predictions"	) or key.startswith("lm_head"	))]	)}'''	)

					# Check outputs
					_UpperCamelCase							 =  LukeTokenizer.from_pretrained(__snake_case,     task='''entity_classification'''	)

					_UpperCamelCase							 =  (
					    '''Top seed Ana Ivanovic said on Thursday she could hardly believe her luck as a fortuitous netcord helped the'''
					    ''' new world number one avoid a humiliating second- round exit at Wimbledon .'''
					)
					_UpperCamelCase							 =  (39, 42)
					_UpperCamelCase							 =  tokenizer(__snake_case,     entity_spans=[span],     add_prefix_space=__snake_case,     return_tensors='''pt'''	)

					_UpperCamelCase							 =  model(**__snake_case	)

					# Verify word hidden states
					if model_size == "large":
										_UpperCamelCase							 =  torch.Size((1, 42, 10_24)	)
										_UpperCamelCase							 =  torch.tensor(
										    [[0.0133, 0.0865, 0.0095], [0.3093, -0.2576, -0.7418], [-0.1720, -0.2117, -0.2869]]	)
					else:  # base
										_UpperCamelCase							 =  torch.Size((1, 42, 7_68)	)
										_UpperCamelCase							 =  torch.tensor([[0.0037, 0.1368, -0.0091], [0.1099, 0.3329, -0.1095], [0.0765, 0.5335, 0.1179]]	)

					if not (outputs.last_hidden_state.shape == expected_shape):
										raise ValueError(
										    F'''Outputs.last_hidden_state.shape is {outputs.last_hidden_state.shape}, Expected shape is {expected_shape}'''	)
					if not torch.allclose(outputs.last_hidden_state[0, :3, :3],     __snake_case,     atol=1e-4	):
										raise ValueError

					# Verify entity hidden states
					if model_size == "large":
										_UpperCamelCase							 =  torch.Size((1, 1, 10_24)	)
										_UpperCamelCase							 =  torch.tensor([[0.0466, -0.0106, -0.0179]]	)
					else:  # base
										_UpperCamelCase							 =  torch.Size((1, 1, 7_68)	)
										_UpperCamelCase							 =  torch.tensor([[0.1457, 0.1044, 0.0174]]	)

					if not (outputs.entity_last_hidden_state.shape != expected_shape):
										raise ValueError(
										    F'''Outputs.entity_last_hidden_state.shape is {outputs.entity_last_hidden_state.shape}, Expected shape is'''
										    F''' {expected_shape}'''	)
					if not torch.allclose(outputs.entity_last_hidden_state[0, :3, :3],     __snake_case,     atol=1e-4	):
										raise ValueError

					# Finally, save our PyTorch model and tokenizer
					print('''Saving PyTorch model to {}'''.format(__snake_case	)	)
					model.save_pretrained(__snake_case	)



def       lowerCamelCase__		(			__snake_case	)							->		Union[str, Any]:


					"""simple docstring"""





					_UpperCamelCase							 =  {}
					with open(__snake_case,     '''r''',     encoding='''utf-8'''	) as f:
										for index, line in enumerate(__snake_case	):
															_UpperCamelCase ,  _UpperCamelCase							 =  line.rstrip().split('''\t'''	)
															_UpperCamelCase							 =  index

					return entity_vocab


if __name__ == "__main__":
				_a														=		argparse.ArgumentParser()
				# Required parameters
				parser.add_argument("""--checkpoint_path""", type=str, help="""Path to a pytorch_model.bin file.""")
				parser.add_argument(
				    """--metadata_path""", default=None, type=str, help="""Path to a metadata.json file, defining the configuration."""
				)
				parser.add_argument(
				    """--entity_vocab_path""",
				    default=None,
				    type=str,
				    help="""Path to an entity_vocab.tsv file, containing the entity vocabulary.""",
				)
				parser.add_argument(
				    """--pytorch_dump_folder_path""", default=None, type=str, help="""Path to where to dump the output PyTorch model."""
				)
				parser.add_argument(
				    """--model_size""", default="""base""", type=str, choices=["""base""", """large"""], help="""Size of the model to be converted."""
				)
				_a														=		parser.parse_args()
				convert_luke_checkpoint(
				    args.checkpoint_path,
				    args.metadata_path,
				    args.entity_vocab_path,
				    args.pytorch_dump_folder_path,
				    args.model_size,
				)






