import inspect
import unittest

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

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


if is_torch_available():
						import torch

						from transformers import MobileViTVaForImageClassification, MobileViTVaForSemanticSegmentation, MobileViTVaModel
						from transformers.models.mobilevitva.modeling_mobilevitva import (
						    MOBILEVITV2_PRETRAINED_MODEL_ARCHIVE_LIST,
						    make_divisible,
						)


if is_vision_available():
						from PIL import Image

						from transformers import MobileViTImageProcessor






class      __lowercase					(    _A    ):

						def        __a		(	self				:      int   )							->		Tuple:


									'''simple docstring'''

									lowercase							=		self.config_class(**self.inputs_dict   )
									self.parent.assertTrue(hasattr(__lowerCamelCase							,							'''width_multiplier'''   )   )






class      __lowercase					:

						def __init__(	self				:      str							,							__lowerCamelCase				:      int							,							__lowerCamelCase				:      int=13							,							__lowerCamelCase				:      List[Any]=64							,							__lowerCamelCase				:      Tuple=2							,							__lowerCamelCase				:      Tuple=3							,							__lowerCamelCase				:      int="swish"							,							__lowerCamelCase				:      Optional[int]=3							,							__lowerCamelCase				:      str=32							,							__lowerCamelCase				:      List[str]=0.1							,							__lowerCamelCase				:      int=0.02							,							__lowerCamelCase				:      List[str]=True							,							__lowerCamelCase				:      Union[str, Any]=True							,							__lowerCamelCase				:      Optional[int]=10							,							__lowerCamelCase				:      Tuple=None							,							__lowerCamelCase				:      List[str]=0.25							,							__lowerCamelCase				:      Tuple=0.0							,							__lowerCamelCase				:      List[str]=0.0							,							)							->		Tuple:


									'''simple docstring'''

									lowercase							=		parent
									lowercase							=		batch_size
									lowercase							=		image_size
									lowercase							=		patch_size
									lowercase							=		num_channels
									lowercase							=		make_divisible(5_12 * width_multiplier							,							divisor=8   )
									lowercase							=		hidden_act
									lowercase							=		conv_kernel_size
									lowercase							=		output_stride
									lowercase							=		classifier_dropout_prob
									lowercase							=		use_labels
									lowercase							=		is_training
									lowercase							=		num_labels
									lowercase							=		initializer_range
									lowercase							=		scope
									lowercase							=		width_multiplier
									lowercase							=		ffn_dropout
									lowercase							=		attn_dropout

						def        __a		(	self				:      Optional[Any]   )							->		Optional[Any]:


									'''simple docstring'''

									lowercase							=		floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]   )

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

									lowercase							=		self.get_config()

									return config, pixel_values, labels, pixel_labels

						def        __a		(	self				:      Union[str, Any]   )							->		List[Any]:


									'''simple docstring'''

									return MobileViTVaConfig(
									    image_size=self.image_size							,							patch_size=self.patch_size							,							num_channels=self.num_channels							,							hidden_act=self.hidden_act							,							conv_kernel_size=self.conv_kernel_size							,							output_stride=self.output_stride							,							classifier_dropout_prob=self.classifier_dropout_prob							,							initializer_range=self.initializer_range							,							width_multiplier=self.width_multiplier							,							ffn_dropout=self.ffn_dropout_prob							,							attn_dropout=self.attn_dropout_prob							,							)

						def        __a		(	self				:      List[str]							,							__lowerCamelCase				:      Tuple							,							__lowerCamelCase				:      Optional[Any]							,							__lowerCamelCase				:      Tuple							,							__lowerCamelCase				:      int   )							->		List[Any]:


									'''simple docstring'''

									lowercase							=		MobileViTVaModel(config=__lowerCamelCase   )
									model.to(__lowerCamelCase   )
									model.eval()
									lowercase							=		model(__lowerCamelCase   )
									self.parent.assertEqual(
									    result.last_hidden_state.shape							,							(
									        self.batch_size,
									        self.last_hidden_size,
									        self.image_size // self.output_stride,
									        self.image_size // self.output_stride,
									    )							,							)

						def        __a		(	self				:      int							,							__lowerCamelCase				:      str							,							__lowerCamelCase				:      str							,							__lowerCamelCase				:      List[str]							,							__lowerCamelCase				:      Optional[Any]   )							->		Optional[Any]:


									'''simple docstring'''

									lowercase							=		self.num_labels
									lowercase							=		MobileViTVaForImageClassification(__lowerCamelCase   )
									model.to(__lowerCamelCase   )
									model.eval()
									lowercase							=		model(__lowerCamelCase							,							labels=__lowerCamelCase   )
									self.parent.assertEqual(result.logits.shape							,							(self.batch_size, self.num_labels)   )

						def        __a		(	self				:      Union[str, Any]							,							__lowerCamelCase				:      List[str]							,							__lowerCamelCase				:      Dict							,							__lowerCamelCase				:      Optional[Any]							,							__lowerCamelCase				:      Any   )							->		str:


									'''simple docstring'''

									lowercase							=		self.num_labels
									lowercase							=		MobileViTVaForSemanticSegmentation(__lowerCamelCase   )
									model.to(__lowerCamelCase   )
									model.eval()
									lowercase							=		model(__lowerCamelCase   )
									self.parent.assertEqual(
									    result.logits.shape							,							(
									        self.batch_size,
									        self.num_labels,
									        self.image_size // self.output_stride,
									        self.image_size // self.output_stride,
									    )							,							)
									lowercase							=		model(__lowerCamelCase							,							labels=__lowerCamelCase   )
									self.parent.assertEqual(
									    result.logits.shape							,							(
									        self.batch_size,
									        self.num_labels,
									        self.image_size // self.output_stride,
									        self.image_size // self.output_stride,
									    )							,							)



						def        __a		(	self				:      int   )							->		Optional[int]:


									'''simple docstring'''

									lowercase							=		self.prepare_config_and_inputs()
									lowercase		,lowercase		,lowercase		,lowercase							=		config_and_inputs
									lowercase							=		{'''pixel_values''': pixel_values}
									return config, inputs_dict






@require_torch
class      __lowercase					(    _A       ,     _A       ,     unittest.TestCase    ):
						lowercase					 =     (
						    (MobileViTVaModel, MobileViTVaForImageClassification, MobileViTVaForSemanticSegmentation)
						    if is_torch_available()
						    else ()
						)

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

						lowercase					 =     False
						lowercase					 =     False
						lowercase					 =     False
						lowercase					 =     False

						def        __a		(	self				:      str   )							->		Optional[int]:


									'''simple docstring'''

									lowercase							=		MobileViTVaModelTester(self   )
									lowercase							=		MobileViTVaConfigTester(self							,							config_class=__lowerCamelCase							,							has_text_modality=__lowerCamelCase   )

						def        __a		(	self				:      Tuple   )							->		str:


									'''simple docstring'''

									self.config_tester.run_common_tests()

						@unittest.skip(reason='''MobileViTV2 does not use inputs_embeds'''   )
						def        __a		(	self				:      int   )							->		List[str]:


									'''simple docstring'''

									pass

						@unittest.skip(reason='''MobileViTV2 does not support input and output embeddings'''   )
						def        __a		(	self				:      str   )							->		Tuple:


									'''simple docstring'''

									pass

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


									'''simple docstring'''

									pass

						@require_torch_multi_gpu
						@unittest.skip(reason='''Got `CUDA error: misaligned address` for tests after this one being run.'''   )
						def        __a		(	self				:      str   )							->		Dict:


									'''simple docstring'''

									pass

						@unittest.skip('''Will be fixed soon by reducing the size of the model used for common tests.'''   )
						def        __a		(	self				:      Union[str, Any]   )							->		Tuple:


									'''simple docstring'''

									pass

						def        __a		(	self				:      str   )							->		Dict:


									'''simple docstring'''

									lowercase		,lowercase							=		self.model_tester.prepare_config_and_inputs_for_common()

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

												lowercase							=		['''pixel_values''']
												self.assertListEqual(arg_names[:1]							,							__lowerCamelCase   )

						def        __a		(	self				:      List[str]   )							->		Optional[Any]:


									'''simple docstring'''

									lowercase							=		self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*__lowerCamelCase   )

						def        __a		(	self				:      Any   )							->		List[Any]:


									'''simple docstring'''

									def check_hidden_states_output(__lowerCamelCase				:      Any							,							__lowerCamelCase				:      List[Any]							,							__lowerCamelCase				:      Union[str, Any]   ):
												lowercase							=		model_class(__lowerCamelCase   )
												model.to(__lowerCamelCase   )
												model.eval()

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

												lowercase							=		outputs.hidden_states

												lowercase							=		5
												self.assertEqual(len(__lowerCamelCase   )							,							__lowerCamelCase   )

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

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

									lowercase		,lowercase							=		self.model_tester.prepare_config_and_inputs_for_common()

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

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

												check_hidden_states_output(__lowerCamelCase							,							__lowerCamelCase							,							__lowerCamelCase   )

						def        __a		(	self				:      List[str]   )							->		List[str]:


									'''simple docstring'''

									lowercase							=		self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_image_classification(*__lowerCamelCase   )

						def        __a		(	self				:      Optional[Any]   )							->		Tuple:


									'''simple docstring'''

									lowercase							=		self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_semantic_segmentation(*__lowerCamelCase   )



						@slow
						def        __a		(	self				:      List[Any]   )							->		List[Any]:


									'''simple docstring'''

									for model_name in MOBILEVITV2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
												lowercase							=		MobileViTVaModel.from_pretrained(__lowerCamelCase   )
												self.assertIsNotNone(__lowerCamelCase   )






def        __UpperCAmelCase    (       )->       Optional[int]:



			"""simple docstring"""







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






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

						@cached_property
						def        __a		(	self				:      int   )							->		Tuple:


									'''simple docstring'''

									return (
									    MobileViTImageProcessor.from_pretrained('''apple/mobilevitv2-1.0-imagenet1k-256'''   )
									    if is_vision_available()
									    else None
									)

						@slow
						def        __a		(	self				:      Optional[Any]   )							->		Dict:


									'''simple docstring'''

									lowercase							=		MobileViTVaForImageClassification.from_pretrained('''apple/mobilevitv2-1.0-imagenet1k-256'''   ).to(
									    __lowerCamelCase   )

									lowercase							=		self.default_image_processor
									lowercase							=		prepare_img()
									lowercase							=		image_processor(images=__lowerCamelCase							,							return_tensors='''pt'''   ).to(__lowerCamelCase   )

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

									# verify the logits
									lowercase							=		torch.Size((1, 10_00)   )
									self.assertEqual(outputs.logits.shape							,							__lowerCamelCase   )

									lowercase							=		torch.tensor([-1.63_36E00, -7.32_04E-02, -5.18_83E-01]   ).to(__lowerCamelCase   )

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

						@slow
						def        __a		(	self				:      Optional[Any]   )							->		Optional[int]:


									'''simple docstring'''

									lowercase							=		MobileViTVaForSemanticSegmentation.from_pretrained('''shehan97/mobilevitv2-1.0-voc-deeplabv3'''   )
									lowercase							=		model.to(__lowerCamelCase   )

									lowercase							=		MobileViTImageProcessor.from_pretrained('''shehan97/mobilevitv2-1.0-voc-deeplabv3'''   )

									lowercase							=		prepare_img()
									lowercase							=		image_processor(images=__lowerCamelCase							,							return_tensors='''pt'''   ).to(__lowerCamelCase   )

									# forward pass
									with torch.no_grad():
												lowercase							=		model(**__lowerCamelCase   )
									lowercase							=		outputs.logits

									# verify the logits
									lowercase							=		torch.Size((1, 21, 32, 32)   )
									self.assertEqual(logits.shape							,							__lowerCamelCase   )

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

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



						@slow
						def        __a		(	self				:      Union[str, Any]   )							->		List[Any]:


									'''simple docstring'''

									lowercase							=		MobileViTVaForSemanticSegmentation.from_pretrained('''shehan97/mobilevitv2-1.0-voc-deeplabv3'''   )
									lowercase							=		model.to(__lowerCamelCase   )

									lowercase							=		MobileViTImageProcessor.from_pretrained('''shehan97/mobilevitv2-1.0-voc-deeplabv3'''   )

									lowercase							=		prepare_img()
									lowercase							=		image_processor(images=__lowerCamelCase							,							return_tensors='''pt'''   ).to(__lowerCamelCase   )

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

									lowercase							=		outputs.logits.detach().cpu()

									lowercase							=		image_processor.post_process_semantic_segmentation(outputs=__lowerCamelCase							,							target_sizes=[(50, 60)]   )
									lowercase							=		torch.Size((50, 60)   )
									self.assertEqual(segmentation[0].shape							,							__lowerCamelCase   )

									lowercase							=		image_processor.post_process_semantic_segmentation(outputs=__lowerCamelCase   )
									lowercase							=		torch.Size((32, 32)   )
									self.assertEqual(segmentation[0].shape							,							__lowerCamelCase   )






import argparse
import hashlib
import os
import urllib
import warnings

import torch
from torch import nn
from tqdm import tqdm

from transformers import WhisperConfig, WhisperForConditionalGeneration


A_      =      {
    "tiny.en": "https://openaipublic.azureedge.net/main/whisper/models/d3dd57d32accea0b295c96e26691aa14d8822fac7d9d27d5dc00b4ca2826dd03/tiny.en.pt",
    "tiny": "https://openaipublic.azureedge.net/main/whisper/models/65147644a518d12f04e32d6f3b26facc3f8dd46e5390956a9424a650c0ce22b9/tiny.pt",
    "base.en": "https://openaipublic.azureedge.net/main/whisper/models/25a8566e1d0c1e2231d1c762132cd20e0f96a85d16145c3a00adf5d1ac670ead/base.en.pt",
    "base": "https://openaipublic.azureedge.net/main/whisper/models/ed3a0b6b1c0edf879ad9b11b1af5a0e6ab5db9205f891f668f8b0e6c6326e34e/base.pt",
    "small.en": "https://openaipublic.azureedge.net/main/whisper/models/f953ad0fd29cacd07d5a9eda5624af0f6bcf2258be67c92b79389873d91e0872/small.en.pt",
    "small": "https://openaipublic.azureedge.net/main/whisper/models/9ecf779972d90ba49c06d968637d720dd632c55bbf19d441fb42bf17a411e794/small.pt",
    "medium.en": "https://openaipublic.azureedge.net/main/whisper/models/d7440d1dc186f76616474e0ff0b3b6b879abc9d1a4926b7adfa41db2d497ab4f/medium.en.pt",
    "medium": "https://openaipublic.azureedge.net/main/whisper/models/345ae4da62f9b3d59415adc60127b97c714f32e89e936602e85993674d08dcb1/medium.pt",
    "large": "https://openaipublic.azureedge.net/main/whisper/models/e4b87e7e0bf463eb8e6956e646f1e277e901512310def2c24bf0e11bd3c28e9a/large.pt",
    "large-v2": "https://openaipublic.azureedge.net/main/whisper/models/81f7c96c852ee8fc832187b0132e569d6c3065a3252ed18e56effd0b6a73e524/large-v2.pt",
}






def        __UpperCAmelCase    (       UpperCAmelCase       )->       Dict:



			"""simple docstring"""







			lowercase							=		['''layers''', '''blocks''']
			for k in ignore_keys:
						state_dict.pop(UpperCAmelCase,		UpperCAmelCase       )


A_      =      {
    "blocks": "layers",
    "mlp.0": "fc1",
    "mlp.2": "fc2",
    "mlp_ln": "final_layer_norm",
    ".attn.query": ".self_attn.q_proj",
    ".attn.key": ".self_attn.k_proj",
    ".attn.value": ".self_attn.v_proj",
    ".attn_ln": ".self_attn_layer_norm",
    ".attn.out": ".self_attn.out_proj",
    ".cross_attn.query": ".encoder_attn.q_proj",
    ".cross_attn.key": ".encoder_attn.k_proj",
    ".cross_attn.value": ".encoder_attn.v_proj",
    ".cross_attn_ln": ".encoder_attn_layer_norm",
    ".cross_attn.out": ".encoder_attn.out_proj",
    "decoder.ln.": "decoder.layer_norm.",
    "encoder.ln.": "encoder.layer_norm.",
    "token_embedding": "embed_tokens",
    "encoder.positional_embedding": "encoder.embed_positions.weight",
    "decoder.positional_embedding": "decoder.embed_positions.weight",
    "ln_post": "layer_norm",
}






def        __UpperCAmelCase    (       UpperCAmelCase       )->       List[str]:



			"""simple docstring"""







			lowercase							=		list(s_dict.keys()       )
			for key in keys:
						lowercase							=		key
						for k, v in WHISPER_MAPPING.items():
									if k in key:
												lowercase							=		new_key.replace(UpperCAmelCase,		UpperCAmelCase       )

						print(f'{key} -> {new_key}'       )

						lowercase							=		s_dict.pop(UpperCAmelCase       )
			return s_dict






def        __UpperCAmelCase    (       UpperCAmelCase       )->       str:



			"""simple docstring"""







			lowercase		,lowercase							=		emb.weight.shape
			lowercase							=		nn.Linear(UpperCAmelCase,		UpperCAmelCase,		bias=UpperCAmelCase       )
			lowercase							=		emb.weight.data
			return lin_layer






def        __UpperCAmelCase    (       UpperCAmelCase,		UpperCAmelCase       )->       bytes:



			"""simple docstring"""







			os.makedirs(UpperCAmelCase,		exist_ok=UpperCAmelCase       )
			lowercase							=		os.path.basename(UpperCAmelCase       )

			lowercase							=		url.split('''/'''       )[-2]
			lowercase							=		os.path.join(UpperCAmelCase,		UpperCAmelCase       )

			if os.path.exists(UpperCAmelCase       ) and not os.path.isfile(UpperCAmelCase       ):
						raise RuntimeError(f'{download_target} exists and is not a regular file'       )

			if os.path.isfile(UpperCAmelCase       ):
						lowercase							=		open(UpperCAmelCase,		'''rb'''       ).read()
						if hashlib.shaaaa(UpperCAmelCase       ).hexdigest() == expected_shaaaa:
									return model_bytes
						else:
									warnings.warn(f'{download_target} exists, but the SHA256 checksum does not match; re-downloading the file'       )

			with urllib.request.urlopen(UpperCAmelCase       ) as source, open(UpperCAmelCase,		'''wb'''       ) as output:
						with tqdm(
						    total=int(source.info().get('''Content-Length'''       )       ),		ncols=80,		unit='''iB''',		unit_scale=UpperCAmelCase,		unit_divisor=1024       ) as loop:
									while True:
												lowercase							=		source.read(8192       )
												if not buffer:
															break

												output.write(UpperCAmelCase       )
												loop.update(len(UpperCAmelCase       )       )

			lowercase							=		open(UpperCAmelCase,		'''rb'''       ).read()
			if hashlib.shaaaa(UpperCAmelCase       ).hexdigest() != expected_shaaaa:
						raise RuntimeError(
						    '''Model has been downloaded but the SHA256 checksum does not not match. Please retry loading the model.'''       )

			return model_bytes






def        __UpperCAmelCase    (       UpperCAmelCase,		UpperCAmelCase       )->       Union[str, Any]:



			"""simple docstring"""







			if ".pt" not in checkpoint_path:
						lowercase							=		_download(_MODELS[checkpoint_path]       )
			else:
						lowercase							=		torch.load(UpperCAmelCase,		map_location='''cpu'''       )
			lowercase							=		original_checkpoint['''dims''']
			lowercase							=		original_checkpoint['''model_state_dict''']
			lowercase							=		state_dict['''decoder.token_embedding.weight''']
			remove_ignore_keys_(UpperCAmelCase       )
			rename_keys(UpperCAmelCase       )
			lowercase							=		True
			lowercase							=		state_dict['''decoder.layers.0.fc1.weight'''].shape[0]

			lowercase							=		WhisperConfig(
			    vocab_size=dimensions['''n_vocab'''],		encoder_ffn_dim=UpperCAmelCase,		decoder_ffn_dim=UpperCAmelCase,		num_mel_bins=dimensions['''n_mels'''],		d_model=dimensions['''n_audio_state'''],		max_target_positions=dimensions['''n_text_ctx'''],		encoder_layers=dimensions['''n_audio_layer'''],		encoder_attention_heads=dimensions['''n_audio_head'''],		decoder_layers=dimensions['''n_text_layer'''],		decoder_attention_heads=dimensions['''n_text_state'''],		max_source_positions=dimensions['''n_audio_ctx'''],		)

			lowercase							=		WhisperForConditionalGeneration(UpperCAmelCase       )
			lowercase		,lowercase							=		model.model.load_state_dict(UpperCAmelCase,		strict=UpperCAmelCase       )
			if len(UpperCAmelCase       ) > 0 and not set(UpperCAmelCase       ) <= {
			    "encoder.embed_positions.weights",
			    "decoder.embed_positions.weights",
			}:
						raise ValueError(
						    '''Only `encoder.embed_positions.weights` and `decoder.embed_positions.weights`  are allowed to be missing,'''
						    f' but all the following weights are missing {missing}'       )

			if tie_embeds:
						lowercase							=		make_linear_from_emb(model.model.decoder.embed_tokens       )
			else:
						lowercase							=		proj_out_weights

			model.save_pretrained(UpperCAmelCase       )


if __name__ == "__main__":
						A_      =      argparse.ArgumentParser()
						# # Required parameters
						parser.add_argument("--checkpoint_path", type=str, help="Patht to the downloaded checkpoints")
						parser.add_argument("--pytorch_dump_folder_path", default=None, type=str, help="Path to the output PyTorch model.")
						A_      =      parser.parse_args()

						convert_openai_whisper_to_tfms(args.checkpoint_path, args.pytorch_dump_folder_path)





