


'''simple docstring'''






import inspect
import unittest

from datasets import load_dataset
from packaging import version

from transformers import BeitConfig
from transformers.models.auto import get_values
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, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
							import torch
							from torch import nn

							from transformers import (
							    MODEL_MAPPING,
							    BeitForImageClassification,
							    BeitForMaskedImageModeling,
							    BeitForSemanticSegmentation,
							    BeitModel,
							)
							from transformers.models.beit.modeling_beit import BEIT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
							import PIL
							from PIL import Image

							from transformers import BeitImageProcessor
class     __UpperCamelCase						:





							def __init__(	self		:List[Any]	,_UpperCamelCase		:str	,_UpperCamelCase		:Optional[int]=1_0_0	,_UpperCamelCase		:Tuple=1_3	,_UpperCamelCase		:int=3_0	,_UpperCamelCase		:int=2	,_UpperCamelCase		:List[Any]=3	,_UpperCamelCase		:Optional[Any]=True	,_UpperCamelCase		:List[Any]=True	,_UpperCamelCase		:int=3_2	,_UpperCamelCase		:str=4	,_UpperCamelCase		:Optional[int]=4	,_UpperCamelCase		:Tuple=3_7	,_UpperCamelCase		:str="gelu"	,_UpperCamelCase		:Union[str, Any]=0.1	,_UpperCamelCase		:Tuple=0.1	,_UpperCamelCase		:Dict=1_0	,_UpperCamelCase		:Any=0.02	,_UpperCamelCase		:List[str]=3	,_UpperCamelCase		:List[str]=None	,_UpperCamelCase		:Optional[int]=[0, 1, 2, 3]	,):
									snake_case_		:				Union[str, Any]      							=    parent
									snake_case_		:				Optional[int]      							=    1_0_0
									snake_case_		:				Tuple      							=    batch_size
									snake_case_		:				Optional[Any]      							=    image_size
									snake_case_		:				Optional[Any]      							=    patch_size
									snake_case_		:				Any      							=    num_channels
									snake_case_		:				List[str]      							=    is_training
									snake_case_		:				Dict      							=    use_labels
									snake_case_		:				Union[str, Any]      							=    hidden_size
									snake_case_		:				int      							=    num_hidden_layers
									snake_case_		:				Any      							=    num_attention_heads
									snake_case_		:				int      							=    intermediate_size
									snake_case_		:				List[Any]      							=    hidden_act
									snake_case_		:				Optional[int]      							=    hidden_dropout_prob
									snake_case_		:				Optional[Any]      							=    attention_probs_dropout_prob
									snake_case_		:				int      							=    type_sequence_label_size
									snake_case_		:				Union[str, Any]      							=    initializer_range
									snake_case_		:				List[str]      							=    scope
									snake_case_		:				Dict      							=    out_indices
									snake_case_		:				Union[str, Any]      							=    num_labels

									# in BeiT, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
									snake_case_		:				Tuple      							=    (image_size // patch_size) ** 2
									snake_case_		:				str      							=    num_patches + 1





							def 		a__ (	self		:List[str]      ):
									snake_case_		:				Dict      							=    floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]      )

									snake_case_		:				Any      							=    None
									snake_case_		:				List[str]      							=    None
									if self.use_labels:
											snake_case_		:				Dict      							=    ids_tensor([self.batch_size]	,self.type_sequence_label_size      )
											snake_case_		:				Optional[Any]      							=    ids_tensor([self.batch_size, self.image_size, self.image_size]	,self.num_labels      )

									snake_case_		:				int      							=    self.get_config()

									return config, pixel_values, labels, pixel_labels





							def 		a__ (	self		:List[Any]      ):
									return BeitConfig(
									    vocab_size=self.vocab_size	,image_size=self.image_size	,patch_size=self.patch_size	,num_channels=self.num_channels	,hidden_size=self.hidden_size	,num_hidden_layers=self.num_hidden_layers	,num_attention_heads=self.num_attention_heads	,intermediate_size=self.intermediate_size	,hidden_act=self.hidden_act	,hidden_dropout_prob=self.hidden_dropout_prob	,attention_probs_dropout_prob=self.attention_probs_dropout_prob	,is_decoder=__a	,initializer_range=self.initializer_range	,out_indices=self.out_indices	,)





							def 		a__ (	self		:str	,_UpperCamelCase		:str	,_UpperCamelCase		:Union[str, Any]	,_UpperCamelCase		:List[Any]	,_UpperCamelCase		:Dict      ):
									snake_case_		:				Any      							=    BeitModel(config=__a      )
									model.to(__a      )
									model.eval()
									snake_case_		:				Tuple      							=    model(__a      )
									self.parent.assertEqual(result.last_hidden_state.shape	,(self.batch_size, self.seq_length, self.hidden_size)      )





							def 		a__ (	self		:Any	,_UpperCamelCase		:Tuple	,_UpperCamelCase		:List[str]	,_UpperCamelCase		:Optional[int]	,_UpperCamelCase		:Any      ):
									snake_case_		:				Union[str, Any]      							=    BeitForMaskedImageModeling(config=__a      )
									model.to(__a      )
									model.eval()
									snake_case_		:				Tuple      							=    model(__a      )
									self.parent.assertEqual(result.logits.shape	,(self.batch_size, self.seq_length - 1, self.vocab_size)      )





							def 		a__ (	self		:str	,_UpperCamelCase		:Optional[Any]	,_UpperCamelCase		:str	,_UpperCamelCase		:List[Any]	,_UpperCamelCase		:Optional[int]      ):
									snake_case_		:				List[Any]      							=    self.type_sequence_label_size
									snake_case_		:				Any      							=    BeitForImageClassification(__a      )
									model.to(__a      )
									model.eval()
									snake_case_		:				List[str]      							=    model(__a	,labels=__a      )
									self.parent.assertEqual(result.logits.shape	,(self.batch_size, self.type_sequence_label_size)      )

									# test greyscale images
									snake_case_		:				Dict      							=    1
									snake_case_		:				str      							=    BeitForImageClassification(__a      )
									model.to(__a      )
									model.eval()

									snake_case_		:				int      							=    floats_tensor([self.batch_size, 1, self.image_size, self.image_size]      )
									snake_case_		:				List[Any]      							=    model(__a	,labels=__a      )
									self.parent.assertEqual(result.logits.shape	,(self.batch_size, self.type_sequence_label_size)      )





							def 		a__ (	self		:List[str]	,_UpperCamelCase		:Union[str, Any]	,_UpperCamelCase		:Optional[Any]	,_UpperCamelCase		:List[str]	,_UpperCamelCase		:Dict      ):
									snake_case_		:				List[str]      							=    self.num_labels
									snake_case_		:				Optional[int]      							=    BeitForSemanticSegmentation(__a      )
									model.to(__a      )
									model.eval()
									snake_case_		:				Union[str, Any]      							=    model(__a      )
									self.parent.assertEqual(
									    result.logits.shape	,(self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2)      )
									snake_case_		:				Dict      							=    model(__a	,labels=__a      )
									self.parent.assertEqual(
									    result.logits.shape	,(self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2)      )





							def 		a__ (	self		:Optional[int]      ):
									snake_case_		:				Dict      							=    self.prepare_config_and_inputs()
									snake_case_		:				Optional[Any]      							=    config_and_inputs
									snake_case_		:				Any      							=    {"pixel_values": pixel_values}
									return config, inputs_dict





@require_torch
class     __UpperCamelCase						(    _UpperCamelCase    ,	_UpperCamelCase    ,	unittest.TestCase				):
							lowercase      :		List[Any] 		=	(
							    (BeitModel, BeitForImageClassification, BeitForMaskedImageModeling, BeitForSemanticSegmentation)
							    if is_torch_available()
							    else ()
							)
							lowercase      :		List[str] 		=	(
							    {
							        "feature-extraction": BeitModel,
							        "image-classification": BeitForImageClassification,
							        "image-segmentation": BeitForSemanticSegmentation,
							    }
							    if is_torch_available()
							    else {}
							)

							lowercase      :		Tuple 		=	False
							lowercase      :		str 		=	False
							lowercase      :		Union[str, Any] 		=	False





							def 		a__ (	self		:List[Any]      ):
									snake_case_		:				Optional[Any]      							=    BeitModelTester(self      )
									snake_case_		:				Union[str, Any]      							=    ConfigTester(self	,config_class=__a	,has_text_modality=__a	,hidden_size=3_7      )





							def 		a__ (	self		:List[str]      ):
									self.config_tester.run_common_tests()





							@unittest.skip(reason="""BEiT does not use inputs_embeds"""      )
							def 		a__ (	self		:Union[str, Any]      ):
									pass





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





							def 		a__ (	self		:int      ):
									snake_case_		:				Optional[int]      							=    self.model_tester.prepare_config_and_inputs_for_common()

									for model_class in self.all_model_classes:
											snake_case_		:				Tuple      							=    model_class(__a      )
											self.assertIsInstance(model.get_input_embeddings()	,(nn.Module)      )
											snake_case_		:				Union[str, Any]      							=    model.get_output_embeddings()
											self.assertTrue(x is None or isinstance(__a	,nn.Linear      )      )





							def 		a__ (	self		:Optional[Any]      ):
									snake_case_		:				Union[str, Any]      							=    self.model_tester.prepare_config_and_inputs_for_common()

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

											snake_case_		:				Dict      							=    ["pixel_values"]
											self.assertListEqual(arg_names[:1]	,__a      )





							def 		a__ (	self		:int      ):
									snake_case_		:				List[str]      							=    self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*__a      )





							def 		a__ (	self		:Union[str, Any]      ):
									snake_case_		:				Dict      							=    self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_masked_lm(*__a      )





							def 		a__ (	self		:Dict      ):
									snake_case_		:				Any      							=    self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_image_classification(*__a      )





							def 		a__ (	self		:Optional[Any]      ):
									snake_case_		:				int      							=    self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_for_semantic_segmentation(*__a      )





							def 		a__ (	self		:List[Any]      ):
									if not self.model_tester.is_training:
											return

									snake_case_		:				Optional[int]      							=    self.model_tester.prepare_config_and_inputs_for_common()
									snake_case_		:				List[Any]      							=    True

									for model_class in self.all_model_classes:
											# we don't test BeitForMaskedImageModeling
											if model_class in [*get_values(__a      ), BeitForMaskedImageModeling]:
													continue

											snake_case_		:				str      							=    model_class(__a      )
											model.to(__a      )
											model.train()
											snake_case_		:				Optional[Any]      							=    self._prepare_for_class(__a	,__a	,return_labels=__a      )
											snake_case_		:				List[str]      							=    model(**__a      ).loss
											loss.backward()





							def 		a__ (	self		:int      ):
									snake_case_		:				List[Any]      							=    self.model_tester.prepare_config_and_inputs_for_common()
									if not self.model_tester.is_training:
											return

									snake_case_		:				Optional[Any]      							=    False
									snake_case_		:				Any      							=    True

									for model_class in self.all_model_classes:
											# we don't test BeitForMaskedImageModeling
											if (
											    model_class in [*get_values(__a      ), BeitForMaskedImageModeling]
											    or not model_class.supports_gradient_checkpointing
											):
													continue

											snake_case_		:				Optional[Any]      							=    model_class(__a      )
											model.gradient_checkpointing_enable()
											model.to(__a      )
											model.train()
											snake_case_		:				List[Any]      							=    self._prepare_for_class(__a	,__a	,return_labels=__a      )
											snake_case_		:				List[str]      							=    model(**__a      ).loss
											loss.backward()





							def 		a__ (	self		:Union[str, Any]      ):
									snake_case_		:				int      							=    self.model_tester.prepare_config_and_inputs_for_common()

									snake_case_		:				Any      							=    _config_zero_init(__a      )
									for model_class in self.all_model_classes:
											snake_case_		:				List[str]      							=    model_class(config=__a      )
											for name, param in model.named_parameters():
													# we skip lambda parameters as these require special initial values
													# determined by config.layer_scale_init_value
													if "lambda" in name:
															continue
													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'''	,)





							@slow
							def 		a__ (	self		:Tuple      ):
									for model_name in BEIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											snake_case_		:				Optional[Any]      							=    BeitModel.from_pretrained(__a      )
											self.assertIsNotNone(__a      )





def   UpperCAmelCase   (		):







		'''simple docstring'''
		snake_case_		:				List[Any]      							=    Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""			)
		return image






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





							@cached_property
							def 		a__ (	self		:List[str]      ):
									return BeitImageProcessor.from_pretrained("""microsoft/beit-base-patch16-224"""      ) if is_vision_available() else None





							@slow
							def 		a__ (	self		:Optional[Any]      ):
									snake_case_		:				int      							=    BeitForMaskedImageModeling.from_pretrained("""microsoft/beit-base-patch16-224-pt22k"""      ).to(__a      )

									snake_case_		:				str      							=    self.default_image_processor
									snake_case_		:				List[str]      							=    prepare_img()
									snake_case_		:				int      							=    image_processor(images=__a	,return_tensors="""pt"""      ).pixel_values.to(__a      )

									# prepare bool_masked_pos
									snake_case_		:				Tuple      							=    torch.ones((1, 1_9_6)	,dtype=torch.bool      ).to(__a      )

									# forward pass
									with torch.no_grad():
											snake_case_		:				Optional[Any]      							=    model(pixel_values=__a	,bool_masked_pos=__a      )
									snake_case_		:				Optional[int]      							=    outputs.logits

									# verify the logits
									snake_case_		:				Dict      							=    torch.Size((1, 1_9_6, 8_1_9_2)      )
									self.assertEqual(logits.shape	,__a      )

									snake_case_		:				Optional[int]      							=    torch.tensor(
									    [[-3.24_37, 0.50_72, -13.91_74], [-3.24_56, 0.49_48, -13.94_01], [-3.20_33, 0.51_21, -13.85_50]]      ).to(__a      )

									self.assertTrue(torch.allclose(logits[bool_masked_pos][:3, :3]	,__a	,atol=1E-2      )      )





							@slow
							def 		a__ (	self		:Optional[Any]      ):
									snake_case_		:				str      							=    BeitForImageClassification.from_pretrained("""microsoft/beit-base-patch16-224"""      ).to(__a      )

									snake_case_		:				str      							=    self.default_image_processor
									snake_case_		:				Optional[int]      							=    prepare_img()
									snake_case_		:				List[Any]      							=    image_processor(images=__a	,return_tensors="""pt"""      ).to(__a      )

									# forward pass
									with torch.no_grad():
											snake_case_		:				int      							=    model(**__a      )
									snake_case_		:				int      							=    outputs.logits

									# verify the logits
									snake_case_		:				Tuple      							=    torch.Size((1, 1_0_0_0)      )
									self.assertEqual(logits.shape	,__a      )

									snake_case_		:				Dict      							=    torch.tensor([-1.23_85, -1.09_87, -1.01_08]      ).to(__a      )

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

									snake_case_		:				List[Any]      							=    2_8_1
									self.assertEqual(logits.argmax(-1      ).item()	,__a      )





							@slow
							def 		a__ (	self		:Dict      ):
									snake_case_		:				Any      							=    BeitForImageClassification.from_pretrained("""microsoft/beit-large-patch16-224-pt22k-ft22k"""      ).to(
									    __a      )

									snake_case_		:				List[Any]      							=    self.default_image_processor
									snake_case_		:				Union[str, Any]      							=    prepare_img()
									snake_case_		:				Union[str, Any]      							=    image_processor(images=__a	,return_tensors="""pt"""      ).to(__a      )

									# forward pass
									with torch.no_grad():
											snake_case_		:				Any      							=    model(**__a      )
									snake_case_		:				str      							=    outputs.logits

									# verify the logits
									snake_case_		:				List[Any]      							=    torch.Size((1, 2_1_8_4_1)      )
									self.assertEqual(logits.shape	,__a      )

									snake_case_		:				int      							=    torch.tensor([1.68_81, -0.27_87, 0.59_01]      ).to(__a      )

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

									snake_case_		:				str      							=    2_3_9_6
									self.assertEqual(logits.argmax(-1      ).item()	,__a      )





							@slow
							def 		a__ (	self		:int      ):
									snake_case_		:				List[str]      							=    BeitForSemanticSegmentation.from_pretrained("""microsoft/beit-base-finetuned-ade-640-640"""      )
									snake_case_		:				str      							=    model.to(__a      )

									snake_case_		:				Any      							=    BeitImageProcessor(do_resize=__a	,size=6_4_0	,do_center_crop=__a      )

									snake_case_		:				Tuple      							=    load_dataset("""hf-internal-testing/fixtures_ade20k"""	,split="""test"""      )
									snake_case_		:				Dict      							=    Image.open(ds[0]["""file"""]      )
									snake_case_		:				Optional[Any]      							=    image_processor(images=__a	,return_tensors="""pt"""      ).to(__a      )

									# forward pass
									with torch.no_grad():
											snake_case_		:				Optional[Any]      							=    model(**__a      )
									snake_case_		:				List[Any]      							=    outputs.logits

									# verify the logits
									snake_case_		:				Any      							=    torch.Size((1, 1_5_0, 1_6_0, 1_6_0)      )
									self.assertEqual(logits.shape	,__a      )

									snake_case_		:				int      							=    version.parse(PIL.__version__      ) < version.parse("""9.0.0"""      )

									if is_pillow_less_than_a:
											snake_case_		:				Tuple      							=    torch.tensor(
											    [
											        [[-4.92_25, -2.39_54, -3.05_22], [-2.88_22, -1.00_46, -1.75_61], [-2.95_49, -1.32_28, -2.13_47]],
											        [[-5.81_68, -3.41_29, -4.07_78], [-3.86_51, -2.22_14, -3.02_77], [-3.83_56, -2.46_43, -3.35_35]],
											        [[-0.00_78, 3.99_52, 4.07_54], [2.98_56, 4.69_44, 5.00_35], [3.24_13, 4.78_13, 4.99_69]],
											    ]	,device=__a	,)
									else:
											snake_case_		:				List[Any]      							=    torch.tensor(
											    [
											        [[-4.89_60, -2.36_88, -3.03_55], [-2.84_78, -0.98_36, -1.74_18], [-2.94_49, -1.33_32, -2.14_56]],
											        [[-5.80_81, -3.41_24, -4.10_06], [-3.85_61, -2.20_81, -3.03_23], [-3.83_65, -2.46_01, -3.36_69]],
											        [[-0.03_09, 3.98_68, 4.05_40], [2.96_40, 4.68_77, 4.99_76], [3.20_81, 4.76_90, 4.99_42]],
											    ]	,device=__a	,)

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





							@slow
							def 		a__ (	self		:List[str]      ):
									snake_case_		:				int      							=    BeitForSemanticSegmentation.from_pretrained("""microsoft/beit-base-finetuned-ade-640-640"""      )
									snake_case_		:				List[str]      							=    model.to(__a      )

									snake_case_		:				Union[str, Any]      							=    BeitImageProcessor(do_resize=__a	,size=6_4_0	,do_center_crop=__a      )

									snake_case_		:				Union[str, Any]      							=    load_dataset("""hf-internal-testing/fixtures_ade20k"""	,split="""test"""      )
									snake_case_		:				Any      							=    Image.open(ds[0]["""file"""]      )
									snake_case_		:				Optional[Any]      							=    image_processor(images=__a	,return_tensors="""pt"""      ).to(__a      )

									# forward pass
									with torch.no_grad():
											snake_case_		:				Tuple      							=    model(**__a      )

									snake_case_		:				Optional[Any]      							=    outputs.logits.detach().cpu()

									snake_case_		:				str      							=    image_processor.post_process_semantic_segmentation(outputs=__a	,target_sizes=[(5_0_0, 3_0_0)]      )
									snake_case_		:				str      							=    torch.Size((5_0_0, 3_0_0)      )
									self.assertEqual(segmentation[0].shape	,__a      )

									snake_case_		:				List[str]      							=    image_processor.post_process_semantic_segmentation(outputs=__a      )
									snake_case_		:				Any      							=    torch.Size((1_6_0, 1_6_0)      )
									self.assertEqual(segmentation[0].shape	,__a      )






"""simple docstring"""


import argparse

import torch
from torch import nn

from transformers import MBartConfig, MBartForConditionalGeneration




def        lowercase__     (       lowercase_      )       ->		Tuple:




      """simple docstring"""

      _UpperCamelCase   :						Optional[int]    =							[
          "encoder.version",
          "decoder.version",
          "model.encoder.version",
          "model.decoder.version",
          "_float_tensor",
          "decoder.output_projection.weight",
      ]
      for k in ignore_keys:
            state_dict.pop(lowercase_		,lowercase_      )




def        lowercase__     (       lowercase_      )       ->		List[Any]:




      """simple docstring"""

      _UpperCamelCase,	_UpperCamelCase   :						Union[str, Any]    =							emb.weight.shape
      _UpperCamelCase   :						str    =							nn.Linear(lowercase_		,lowercase_		,bias=lowercase_      )
      _UpperCamelCase   :						List[Any]    =							emb.weight.data
      return lin_layer




def        lowercase__     (       lowercase_		,lowercase_="facebook/mbart-large-en-ro"		,lowercase_=False		,lowercase_=False      )       ->		List[str]:




      """simple docstring"""

      _UpperCamelCase   :						int    =							torch.load(lowercase_		,map_location="cpu"      )["model"]
      remove_ignore_keys_(lowercase_      )
      _UpperCamelCase   :						str    =							state_dict["encoder.embed_tokens.weight"].shape[0]

      _UpperCamelCase   :						int    =							MBartConfig.from_pretrained(lowercase_		,vocab_size=lowercase_      )
      if mbart_aa and finetuned:
            _UpperCamelCase   :						Union[str, Any]    =							"relu"

      _UpperCamelCase   :						Optional[int]    =							state_dict["decoder.embed_tokens.weight"]
      _UpperCamelCase   :						List[str]    =							MBartForConditionalGeneration(lowercase_      )
      model.model.load_state_dict(lowercase_      )

      if finetuned:
            _UpperCamelCase   :						Optional[Any]    =							make_linear_from_emb(model.model.shared      )

      return model


if __name__ == "__main__":
  lowerCamelCase__						= argparse.ArgumentParser()
  # Required parameters
  parser.add_argument(
      "fairseq_path", type=str, help="bart.large, bart.large.cnn or a path to a model.pt on local filesystem."
  )
  parser.add_argument("pytorch_dump_folder_path", default=None, type=str, help="Path to the output PyTorch model.")
  parser.add_argument(
      "--hf_config",
      default="facebook/mbart-large-cc25",
      type=str,
      help="Which huggingface architecture to use: mbart-large",
  )
  parser.add_argument("--mbart_50", action="store_true", help="whether the model is mMART-50 checkpoint")
  parser.add_argument("--finetuned", action="store_true", help="whether the model is a fine-tuned checkpoint")
  lowerCamelCase__						= parser.parse_args()
  lowerCamelCase__						= convert_fairseq_mbart_checkpoint_from_disk(
      args.fairseq_path, hf_config_path=args.hf_config, finetuned=args.finetuned, mbart_aa=args.mbart_aa
  )
  model.save_pretrained(args.pytorch_dump_folder_path)
