


import inspect
import unittest

from huggingface_hub import hf_hub_download

from transformers import ConvNextConfig, UperNetConfig
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import is_torch_available, is_vision_available

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


if is_torch_available():
				import torch

				from transformers import UperNetForSemanticSegmentation
				from transformers.models.upernet.modeling_upernet import UPERNET_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
				from PIL import Image

				from transformers import AutoImageProcessor



class 							_UpperCamelCase :

			'''simple docstring'''







			def __init__(  self  : List[Any]       ,  _lowerCamelCase  : Optional[Any]       ,  _lowerCamelCase  : List[str]=1_3       ,  _lowerCamelCase  : List[Any]=3_2       ,  _lowerCamelCase  : str=3       ,  _lowerCamelCase  : Union[str, Any]=4       ,  _lowerCamelCase  : str=[1_0, 2_0, 3_0, 4_0]       ,  _lowerCamelCase  : Optional[Any]=[2, 2, 3, 2]       ,  _lowerCamelCase  : Optional[Any]=True       ,  _lowerCamelCase  : List[str]=True       ,  _lowerCamelCase  : List[Any]=3_7       ,  _lowerCamelCase  : List[str]="gelu"       ,  _lowerCamelCase  : List[str]=1_0       ,  _lowerCamelCase  : Union[str, Any]=0.02       ,  _lowerCamelCase  : int=["stage2", "stage3", "stage4"]       ,  _lowerCamelCase  : Optional[Any]=3       ,  _lowerCamelCase  : Tuple=None       ,  ):






									'''simple docstring'''



									__lowerCamelCase     :      List[Any]       						=						parent
									__lowerCamelCase     :      Dict       						=						batch_size
									__lowerCamelCase     :      List[str]       						=						image_size
									__lowerCamelCase     :      Tuple       						=						num_channels
									__lowerCamelCase     :      Any       						=						num_stages
									__lowerCamelCase     :      List[str]       						=						hidden_sizes
									__lowerCamelCase     :      Optional[Any]       						=						depths
									__lowerCamelCase     :      List[str]       						=						is_training
									__lowerCamelCase     :      Optional[int]       						=						use_labels
									__lowerCamelCase     :      List[Any]       						=						intermediate_size
									__lowerCamelCase     :      Union[str, Any]       						=						hidden_act
									__lowerCamelCase     :      Optional[int]       						=						type_sequence_label_size
									__lowerCamelCase     :      Optional[int]       						=						initializer_range
									__lowerCamelCase     :      str       						=						out_features
									__lowerCamelCase     :      Optional[int]       						=						num_labels
									__lowerCamelCase     :      Any       						=						scope
									__lowerCamelCase     :      Optional[int]       						=						num_stages

			def   _snake_case    (  self  : Tuple							):






									'''simple docstring'''



									__lowerCamelCase     :      Optional[Any]       						=						floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]							)

									__lowerCamelCase     :      Any       						=						None
									if self.use_labels:
															__lowerCamelCase     :      List[Any]       						=						ids_tensor([self.batch_size]       ,  self.type_sequence_label_size							)

									__lowerCamelCase     :      Optional[Any]       						=						self.get_config()

									return config, pixel_values, labels

			def   _snake_case    (  self  : Dict							):






									'''simple docstring'''



									return ConvNextConfig(
									    num_channels=self.num_channels       ,  num_stages=self.num_stages       ,  hidden_sizes=self.hidden_sizes       ,  depths=self.depths       ,  is_training=self.is_training       ,  intermediate_size=self.intermediate_size       ,  hidden_act=self.hidden_act       ,  out_features=self.out_features       ,  )

			def   _snake_case    (  self  : Dict							):






									'''simple docstring'''



									return UperNetConfig(
									    backbone_config=self.get_backbone_config()       ,  hidden_size=5_1_2       ,  pool_scales=[1, 2, 3, 6]       ,  use_auxiliary_head=lowerCamelCase__       ,  auxiliary_loss_weight=0.4       ,  auxiliary_in_channels=4_0       ,  auxiliary_channels=2_5_6       ,  auxiliary_num_convs=1       ,  auxiliary_concat_input=lowerCamelCase__       ,  loss_ignore_index=2_5_5       ,  num_labels=self.num_labels       ,  )

			def   _snake_case    (  self  : Union[str, Any]       ,  _lowerCamelCase  : List[Any]       ,  _lowerCamelCase  : str       ,  _lowerCamelCase  : Optional[Any]							):






									'''simple docstring'''



									__lowerCamelCase     :      List[Any]       						=						UperNetForSemanticSegmentation(config=lowerCamelCase__							)
									model.to(lowerCamelCase__							)
									model.eval()
									__lowerCamelCase     :      str       						=						model(lowerCamelCase__							)
									self.parent.assertEqual(
									    result.logits.shape       ,  (self.batch_size, self.num_labels, self.image_size, self.image_size)							)


			def   _snake_case    (  self  : Optional[Any]							):






									'''simple docstring'''



									__lowerCamelCase     :      List[Any]       						=						self.prepare_config_and_inputs()
									(
									    __lowerCamelCase    
									)     :      int       						=						config_and_inputs
									__lowerCamelCase     :      Tuple       						=						{"pixel_values": pixel_values}
									return config, inputs_dict



@require_torch
class 							_UpperCamelCase (						UpperCAmelCase__,UpperCAmelCase__,unittest.TestCase						):

			'''simple docstring'''







			a_				:							str    = (UperNetForSemanticSegmentation,) if is_torch_available() else ()
			a_				:							Dict    = {"image-segmentation": UperNetForSemanticSegmentation} if is_torch_available() else {}
			a_				:							Optional[Any]    = False
			a_				:							List[Any]    = False
			a_				:							Optional[int]    = False
			a_				:							Optional[int]    = False
			a_				:							Any    = False
			a_				:							Optional[int]    = False

			def   _snake_case    (  self  : Optional[int]							):






									'''simple docstring'''



									__lowerCamelCase     :      List[Any]       						=						UperNetModelTester(self							)
									__lowerCamelCase     :      Tuple       						=						ConfigTester(self       ,  config_class=lowerCamelCase__       ,  has_text_modality=lowerCamelCase__       ,  hidden_size=3_7							)

			def   _snake_case    (  self  : Optional[int]							):






									'''simple docstring'''



									self.create_and_test_config_common_properties()
									self.config_tester.create_and_test_config_to_json_string()
									self.config_tester.create_and_test_config_to_json_file()
									self.config_tester.create_and_test_config_from_and_save_pretrained()
									self.config_tester.create_and_test_config_with_num_labels()
									self.config_tester.check_config_can_be_init_without_params()
									self.config_tester.check_config_arguments_init()

			def   _snake_case    (  self  : Tuple							):






									'''simple docstring'''



									return

			def   _snake_case    (  self  : str							):






									'''simple docstring'''



									__lowerCamelCase     :      Any       						=						self.model_tester.prepare_config_and_inputs_for_common()

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

															__lowerCamelCase     :      List[Any]       						=						["pixel_values"]
															self.assertListEqual(arg_names[:1]       ,  lowerCamelCase__							)

			def   _snake_case    (  self  : Union[str, Any]							):






									'''simple docstring'''



									__lowerCamelCase     :      List[str]       						=						self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_semantic_segmentation(*lowerCamelCase__							)

			@unittest.skip(reason="""UperNet does not use inputs_embeds"""							)
			def   _snake_case    (  self  : Optional[Any]							):






									'''simple docstring'''



									pass

			@unittest.skip(reason="""UperNet does not support input and output embeddings"""							)
			def   _snake_case    (  self  : List[Any]							):






									'''simple docstring'''



									pass

			@unittest.skip(reason="""UperNet does not have a base model"""							)
			def   _snake_case    (  self  : List[str]							):






									'''simple docstring'''



									pass

			@unittest.skip(reason="""UperNet does not have a base model"""							)
			def   _snake_case    (  self  : Optional[int]							):






									'''simple docstring'''



									pass

			@require_torch_multi_gpu
			@unittest.skip(reason="""UperNet has some layers using `add_module` which doesn't work well with `nn.DataParallel`"""							)
			def   _snake_case    (  self  : Optional[Any]							):






									'''simple docstring'''



									pass

			@unittest.skip("""Will be fixed soon by reducing the size of the model used for common tests."""							)
			def   _snake_case    (  self  : str							):






									'''simple docstring'''



									pass

			def   _snake_case    (  self  : Optional[int]							):






									'''simple docstring'''



									def check_hidden_states_output(_lowerCamelCase  : List[str]       ,  _lowerCamelCase  : Tuple       ,  _lowerCamelCase  : Optional[Any]							):
															__lowerCamelCase     :      Dict       						=						model_class(lowerCamelCase__							)
															model.to(lowerCamelCase__							)
															model.eval()

															with torch.no_grad():
																					__lowerCamelCase     :      List[str]       						=						model(**self._prepare_for_class(lowerCamelCase__       ,  lowerCamelCase__							)							)

															__lowerCamelCase     :      int       						=						outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

															__lowerCamelCase     :      List[str]       						=						self.model_tester.num_stages
															self.assertEqual(len(lowerCamelCase__							)       ,  expected_num_stages + 1							)

															# ConvNext's feature maps are of shape (batch_size, num_channels, height, width)
															self.assertListEqual(
															    list(hidden_states[0].shape[-2:]							)       ,  [self.model_tester.image_size // 4, self.model_tester.image_size // 4]       ,  )

									__lowerCamelCase     :      str       						=						self.model_tester.prepare_config_and_inputs_for_common()

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

															# check that output_hidden_states also work using config
															del inputs_dict["output_hidden_states"]
															__lowerCamelCase     :      Optional[Any]       						=						True

															check_hidden_states_output(lowerCamelCase__       ,  lowerCamelCase__       ,  lowerCamelCase__							)

			def   _snake_case    (  self  : Union[str, Any]							):






									'''simple docstring'''



									__lowerCamelCase     :      Union[str, Any]       						=						self.model_tester.prepare_config_and_inputs_for_common()

									__lowerCamelCase     :      Union[str, Any]       						=						_config_zero_init(lowerCamelCase__							)
									__lowerCamelCase     :      str       						=						_config_zero_init(configs_no_init.backbone_config							)
									for model_class in self.all_model_classes:
															__lowerCamelCase     :      Tuple       						=						model_class(config=lowerCamelCase__							)
															for name, param in model.named_parameters():
																					if param.requires_grad:
																											self.assertIn(
																											    ((param.data.mean() * 1E9).round() / 1E9).item()       ,  [0.0, 1.0]       ,  msg=F"""Parameter {name} of model {model_class} seems not properly initialized"""       ,  )

			@unittest.skip(reason="""UperNet does not have tied weights"""							)
			def   _snake_case    (  self  : Dict							):






									'''simple docstring'''



									pass


			@slow
			def   _snake_case    (  self  : int							):






									'''simple docstring'''



									for model_name in UPERNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															__lowerCamelCase     :      str       						=						UperNetForSemanticSegmentation.from_pretrained(lowerCamelCase__							)
															self.assertIsNotNone(lowerCamelCase__							)





def   _UpperCAmelCase       (     ):
						"""simple docstring"""




						__lowerCamelCase     :      Any       						=						hf_hub_download(
						    repo_id="""hf-internal-testing/fixtures_ade20k"""						,	repo_type="""dataset"""						,	filename="""ADE_val_00000001.jpg"""      )
						__lowerCamelCase     :      int       						=						Image.open(__lowerCAmelCase      ).convert("""RGB"""      )
						return image




@require_torch
@require_vision
@slow
class 							_UpperCamelCase (						unittest.TestCase						):

			'''simple docstring'''







			def   _snake_case    (  self  : Tuple							):






									'''simple docstring'''



									__lowerCamelCase     :      List[Any]       						=						AutoImageProcessor.from_pretrained("""openmmlab/upernet-swin-tiny"""							)
									__lowerCamelCase     :      Union[str, Any]       						=						UperNetForSemanticSegmentation.from_pretrained("""openmmlab/upernet-swin-tiny"""							).to(lowerCamelCase__							)

									__lowerCamelCase     :      str       						=						prepare_img()
									__lowerCamelCase     :      Any       						=						processor(images=lowerCamelCase__       ,  return_tensors="""pt"""							).to(lowerCamelCase__							)

									with torch.no_grad():
															__lowerCamelCase     :      Union[str, Any]       						=						model(**lowerCamelCase__							)

									__lowerCamelCase     :      List[Any]       						=						torch.Size((1, model.config.num_labels, 5_1_2, 5_1_2)							)
									self.assertEqual(outputs.logits.shape       ,  lowerCamelCase__							)

									__lowerCamelCase     :      Any       						=						torch.tensor(
									    [[-7.5_958, -7.5_958, -7.4_302], [-7.5_958, -7.5_958, -7.4_302], [-7.4_797, -7.4_797, -7.3_068]]							).to(lowerCamelCase__							)
									self.assertTrue(torch.allclose(outputs.logits[0, 0, :3, :3]       ,  lowerCamelCase__       ,  atol=1E-4							)							)


			def   _snake_case    (  self  : List[str]							):






									'''simple docstring'''



									__lowerCamelCase     :      Dict       						=						AutoImageProcessor.from_pretrained("""openmmlab/upernet-convnext-tiny"""							)
									__lowerCamelCase     :      Dict       						=						UperNetForSemanticSegmentation.from_pretrained("""openmmlab/upernet-convnext-tiny"""							).to(lowerCamelCase__							)

									__lowerCamelCase     :      int       						=						prepare_img()
									__lowerCamelCase     :      List[Any]       						=						processor(images=lowerCamelCase__       ,  return_tensors="""pt"""							).to(lowerCamelCase__							)

									with torch.no_grad():
															__lowerCamelCase     :      Dict       						=						model(**lowerCamelCase__							)

									__lowerCamelCase     :      int       						=						torch.Size((1, model.config.num_labels, 5_1_2, 5_1_2)							)
									self.assertEqual(outputs.logits.shape       ,  lowerCamelCase__							)

									__lowerCamelCase     :      Dict       						=						torch.tensor(
									    [[-8.8_110, -8.8_110, -8.6_521], [-8.8_110, -8.8_110, -8.6_521], [-8.7_746, -8.7_746, -8.6_130]]							).to(lowerCamelCase__							)
									self.assertTrue(torch.allclose(outputs.logits[0, 0, :3, :3]       ,  lowerCamelCase__       ,  atol=1E-4							)							)







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


__UpperCamelCase    :						Tuple     =							{
    '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"""




      __lowerCamelCase     :      int       						=						["""layers""", """blocks"""]
      for k in ignore_keys:
            state_dict.pop(UpperCAmelCase						,	UpperCAmelCase      )


__UpperCamelCase    :						str     =							{
    '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      :			Dict      ):
      """simple docstring"""




      __lowerCamelCase     :      List[str]       						=						list(s_dict.keys()      )
      for key in keys:
            __lowerCamelCase     :      Union[str, Any]       						=						key
            for k, v in WHISPER_MAPPING.items():
                  if k in key:
                        __lowerCamelCase     :      Optional[int]       						=						new_key.replace(UpperCAmelCase						,	UpperCAmelCase      )

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

            __lowerCamelCase     :      Dict       						=						s_dict.pop(UpperCAmelCase      )
      return s_dict





def   _UpperCAmelCase       (     UpperCAmelCase      :			Optional[int]      ):
      """simple docstring"""




      __lowerCamelCase						, __lowerCamelCase     :      Dict       						=						emb.weight.shape
      __lowerCamelCase     :      Tuple       						=						nn.Linear(UpperCAmelCase						,	UpperCAmelCase						,	bias=UpperCAmelCase      )
      __lowerCamelCase     :      Union[str, Any]       						=						emb.weight.data
      return lin_layer





def   _UpperCAmelCase       (     UpperCAmelCase      :			str						,	UpperCAmelCase      :			str      ):
      """simple docstring"""




      os.makedirs(UpperCAmelCase						,	exist_ok=UpperCAmelCase      )
      __lowerCamelCase     :      Any       						=						os.path.basename(UpperCAmelCase      )

      __lowerCamelCase     :      int       						=						url.split("""/"""      )[-2]
      __lowerCamelCase     :      str       						=						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      ):
            __lowerCamelCase     :      Any       						=						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=1_024      ) as loop:
                  while True:
                        __lowerCamelCase     :      Union[str, Any]       						=						source.read(8_192      )
                        if not buffer:
                              break

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

      __lowerCamelCase     :      List[str]       						=						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      :			List[Any]						,	UpperCAmelCase      :			Optional[int]      ):
      """simple docstring"""




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

      __lowerCamelCase     :      Any       						=						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"""]						,	)

      __lowerCamelCase     :      List[str]       						=						WhisperForConditionalGeneration(UpperCAmelCase      )
      __lowerCamelCase						, __lowerCamelCase     :      str       						=						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:
            __lowerCamelCase     :      Tuple       						=						make_linear_from_emb(model.model.decoder.embed_tokens      )
      else:
            __lowerCamelCase     :      Tuple       						=						proj_out_weights

      model.save_pretrained(UpperCAmelCase      )


if __name__ == "__main__":
    __UpperCamelCase    :						Union[str, Any]     =							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.')
    __UpperCamelCase    :						Tuple     =							parser.parse_args()

    convert_openai_whisper_to_tfms(args.checkpoint_path, args.pytorch_dump_folder_path)



