




"""simple docstring"""





import unittest

import numpy as np
from datasets import load_dataset

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
					import torch

if is_vision_available():
					from PIL import Image

					from transformers import BeitImageProcessor



class      a__				(	unittest.TestCase   ):


			def __init__(      self      :    int      ,  UpperCamelCase_      :    Optional[Any]      ,  UpperCamelCase_      :    Optional[int]=7      ,  UpperCamelCase_      :    Union[str, Any]=3      ,  UpperCamelCase_      :    List[Any]=18      ,  UpperCamelCase_      :    Any=30      ,  UpperCamelCase_      :    int=400      ,  UpperCamelCase_      :    Tuple=True      ,  UpperCamelCase_      :    Tuple=None      ,  UpperCamelCase_      :    Optional[int]=True      ,  UpperCamelCase_      :    Dict=None      ,  UpperCamelCase_      :    Optional[int]=True      ,  UpperCamelCase_      :    List[str]=[0.5, 0.5, 0.5]      ,  UpperCamelCase_      :    Tuple=[0.5, 0.5, 0.5]      ,  UpperCamelCase_      :    Dict=False      ,  ):


						"""simple docstring"""




						__UpperCAmelCase	: int		=					size if size is not None else {"height": 20, "width": 20}
						__UpperCAmelCase	: Any		=					crop_size if crop_size is not None else {"height": 18, "width": 18}
						__UpperCAmelCase	: Optional[int]		=					parent
						__UpperCAmelCase	: Any		=					batch_size
						__UpperCAmelCase	: List[Any]		=					num_channels
						__UpperCAmelCase	: Any		=					image_size
						__UpperCAmelCase	: Optional[Any]		=					min_resolution
						__UpperCAmelCase	: str		=					max_resolution
						__UpperCAmelCase	: Union[str, Any]		=					do_resize
						__UpperCAmelCase	: Dict		=					size
						__UpperCAmelCase	: Dict		=					do_center_crop
						__UpperCAmelCase	: str		=					crop_size
						__UpperCAmelCase	: List[str]		=					do_normalize
						__UpperCAmelCase	: Tuple		=					image_mean
						__UpperCAmelCase	: Tuple		=					image_std
						__UpperCAmelCase	: List[str]		=					do_reduce_labels


			def       a_     (      self      :    Dict):


						"""simple docstring"""




						return {
						    "do_resize": self.do_resize,
						    "size": self.size,
						    "do_center_crop": self.do_center_crop,
						    "crop_size": self.crop_size,
						    "do_normalize": self.do_normalize,
						    "image_mean": self.image_mean,
						    "image_std": self.image_std,
						    "do_reduce_labels": self.do_reduce_labels,
						}






def 					_UpperCamelCase    (			)			->			List[Any]:


			"""simple docstring"""
			__UpperCAmelCase	: Optional[int]		=					load_dataset("hf-internal-testing/fixtures_ade20k"				,       split="test"							)

			__UpperCAmelCase	: Optional[Any]		=					Image.open(dataset[0]["file"]							)
			__UpperCAmelCase	: Optional[int]		=					Image.open(dataset[1]["file"]							)

			return image, map

def 					_UpperCamelCase    (			)			->			Tuple:


			"""simple docstring"""
			__UpperCAmelCase	: Any		=					load_dataset("hf-internal-testing/fixtures_ade20k"				,       split="test"							)

			__UpperCAmelCase	: Tuple		=					Image.open(ds[0]["file"]							)
			__UpperCAmelCase	: Optional[Any]		=					Image.open(ds[1]["file"]							)
			__UpperCAmelCase	: Tuple		=					Image.open(ds[2]["file"]							)
			__UpperCAmelCase	: Any		=					Image.open(ds[3]["file"]							)

			return [imagea, imagea], [mapa, mapa]





@require_torch
@require_vision
class      a__				(	__magic_name__							,    unittest.TestCase   ):
			lowercase_    =	BeitImageProcessor if is_vision_available() else None


			def       a_     (      self      :    Optional[int]):


						"""simple docstring"""




						__UpperCAmelCase	: List[Any]		=					BeitImageProcessingTester(self)


			@property
			def       a_     (      self      :    List[str]):


						"""simple docstring"""




						return self.image_processor_tester.prepare_image_processor_dict()


			def       a_     (      self      :    Any):


						"""simple docstring"""




						__UpperCAmelCase	: Tuple		=					self.image_processing_class(**self.image_processor_dict)
						self.assertTrue(hasattr(UpperCamelCase_      ,  "do_resize"))
						self.assertTrue(hasattr(UpperCamelCase_      ,  "size"))
						self.assertTrue(hasattr(UpperCamelCase_      ,  "do_center_crop"))
						self.assertTrue(hasattr(UpperCamelCase_      ,  "center_crop"))
						self.assertTrue(hasattr(UpperCamelCase_      ,  "do_normalize"))
						self.assertTrue(hasattr(UpperCamelCase_      ,  "image_mean"))
						self.assertTrue(hasattr(UpperCamelCase_      ,  "image_std"))


			def       a_     (      self      :    str):


						"""simple docstring"""




						__UpperCAmelCase	: int		=					self.image_processing_class.from_dict(self.image_processor_dict)
						self.assertEqual(image_processor.size      ,  {"height": 20, "width": 20})
						self.assertEqual(image_processor.crop_size      ,  {"height": 18, "width": 18})
						self.assertEqual(image_processor.do_reduce_labels      ,  UpperCamelCase_)

						__UpperCAmelCase	: Optional[Any]		=					self.image_processing_class.from_dict(
						    self.image_processor_dict      ,  size=42      ,  crop_size=84      ,  reduce_labels=UpperCamelCase_)
						self.assertEqual(image_processor.size      ,  {"height": 42, "width": 42})
						self.assertEqual(image_processor.crop_size      ,  {"height": 84, "width": 84})
						self.assertEqual(image_processor.do_reduce_labels      ,  UpperCamelCase_)


			def       a_     (      self      :    Dict):


						"""simple docstring"""




						pass


			def       a_     (      self      :    str):


						"""simple docstring"""




						__UpperCAmelCase	: List[Any]		=					self.image_processing_class(**self.image_processor_dict)
						# create random PIL images
						__UpperCAmelCase	: Union[str, Any]		=					prepare_image_inputs(self.image_processor_tester      ,  equal_resolution=UpperCamelCase_)
						for image in image_inputs:
									self.assertIsInstance(UpperCamelCase_      ,  Image.Image)

						# Test not batched input
						__UpperCAmelCase	: Dict		=					image_processing(image_inputs[0]      ,  return_tensors="pt").pixel_values
						self.assertEqual(
						    encoded_images.shape      ,  (
						        1,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )      ,  )

						# Test batched
						__UpperCAmelCase	: int		=					image_processing(UpperCamelCase_      ,  return_tensors="pt").pixel_values
						self.assertEqual(
						    encoded_images.shape      ,  (
						        self.image_processor_tester.batch_size,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )      ,  )


			def       a_     (      self      :    List[Any]):


						"""simple docstring"""




						__UpperCAmelCase	: Optional[int]		=					self.image_processing_class(**self.image_processor_dict)
						# create random numpy tensors
						__UpperCAmelCase	: Any		=					prepare_image_inputs(self.image_processor_tester      ,  equal_resolution=UpperCamelCase_      ,  numpify=UpperCamelCase_)
						for image in image_inputs:
									self.assertIsInstance(UpperCamelCase_      ,  np.ndarray)

						# Test not batched input
						__UpperCAmelCase	: int		=					image_processing(image_inputs[0]      ,  return_tensors="pt").pixel_values
						self.assertEqual(
						    encoded_images.shape      ,  (
						        1,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )      ,  )

						# Test batched
						__UpperCAmelCase	: Dict		=					image_processing(UpperCamelCase_      ,  return_tensors="pt").pixel_values
						self.assertEqual(
						    encoded_images.shape      ,  (
						        self.image_processor_tester.batch_size,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )      ,  )


			def       a_     (      self      :    List[str]):


						"""simple docstring"""




						__UpperCAmelCase	: List[Any]		=					self.image_processing_class(**self.image_processor_dict)
						# create random PyTorch tensors
						__UpperCAmelCase	: Union[str, Any]		=					prepare_image_inputs(self.image_processor_tester      ,  equal_resolution=UpperCamelCase_      ,  torchify=UpperCamelCase_)
						for image in image_inputs:
									self.assertIsInstance(UpperCamelCase_      ,  torch.Tensor)

						# Test not batched input
						__UpperCAmelCase	: Optional[Any]		=					image_processing(image_inputs[0]      ,  return_tensors="pt").pixel_values
						self.assertEqual(
						    encoded_images.shape      ,  (
						        1,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )      ,  )

						# Test batched
						__UpperCAmelCase	: Dict		=					image_processing(UpperCamelCase_      ,  return_tensors="pt").pixel_values
						self.assertEqual(
						    encoded_images.shape      ,  (
						        self.image_processor_tester.batch_size,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )      ,  )


			def       a_     (      self      :    Dict):


						"""simple docstring"""




						__UpperCAmelCase	: Tuple		=					self.image_processing_class(**self.image_processor_dict)
						# create random PyTorch tensors
						__UpperCAmelCase	: List[str]		=					prepare_image_inputs(self.image_processor_tester      ,  equal_resolution=UpperCamelCase_      ,  torchify=UpperCamelCase_)
						__UpperCAmelCase	: Optional[int]		=					[]
						for image in image_inputs:
									self.assertIsInstance(UpperCamelCase_      ,  torch.Tensor)
									maps.append(torch.zeros(image.shape[-2:]).long())

						# Test not batched input
						__UpperCAmelCase	: Dict		=					image_processing(image_inputs[0]      ,  maps[0]      ,  return_tensors="pt")
						self.assertEqual(
						    encoding["pixel_values"].shape      ,  (
						        1,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )      ,  )
						self.assertEqual(
						    encoding["labels"].shape      ,  (
						        1,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )      ,  )
						self.assertEqual(encoding["labels"].dtype      ,  torch.long)
						self.assertTrue(encoding["labels"].min().item() >= 0)
						self.assertTrue(encoding["labels"].max().item() <= 255)

						# Test batched
						__UpperCAmelCase	: Optional[int]		=					image_processing(UpperCamelCase_      ,  UpperCamelCase_      ,  return_tensors="pt")
						self.assertEqual(
						    encoding["pixel_values"].shape      ,  (
						        self.image_processor_tester.batch_size,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )      ,  )
						self.assertEqual(
						    encoding["labels"].shape      ,  (
						        self.image_processor_tester.batch_size,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )      ,  )
						self.assertEqual(encoding["labels"].dtype      ,  torch.long)
						self.assertTrue(encoding["labels"].min().item() >= 0)
						self.assertTrue(encoding["labels"].max().item() <= 255)

						# Test not batched input (PIL images)
						__UpperCAmelCase	: Optional[Any]		=					prepare_semantic_single_inputs()

						__UpperCAmelCase	: Any		=					image_processing(UpperCamelCase_      ,  UpperCamelCase_      ,  return_tensors="pt")
						self.assertEqual(
						    encoding["pixel_values"].shape      ,  (
						        1,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )      ,  )
						self.assertEqual(
						    encoding["labels"].shape      ,  (
						        1,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )      ,  )
						self.assertEqual(encoding["labels"].dtype      ,  torch.long)
						self.assertTrue(encoding["labels"].min().item() >= 0)
						self.assertTrue(encoding["labels"].max().item() <= 255)

						# Test batched input (PIL images)
						__UpperCAmelCase	: str		=					prepare_semantic_batch_inputs()

						__UpperCAmelCase	: List[str]		=					image_processing(UpperCamelCase_      ,  UpperCamelCase_      ,  return_tensors="pt")
						self.assertEqual(
						    encoding["pixel_values"].shape      ,  (
						        2,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )      ,  )
						self.assertEqual(
						    encoding["labels"].shape      ,  (
						        2,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )      ,  )
						self.assertEqual(encoding["labels"].dtype      ,  torch.long)
						self.assertTrue(encoding["labels"].min().item() >= 0)
						self.assertTrue(encoding["labels"].max().item() <= 255)


			def       a_     (      self      :    Optional[Any]):


						"""simple docstring"""




						__UpperCAmelCase	: Tuple		=					self.image_processing_class(**self.image_processor_dict)

						# ADE20k has 150 classes, and the background is included, so labels should be between 0 and 150
						__UpperCAmelCase	: str		=					prepare_semantic_single_inputs()
						__UpperCAmelCase	: Optional[Any]		=					image_processing(UpperCamelCase_      ,  UpperCamelCase_      ,  return_tensors="pt")
						self.assertTrue(encoding["labels"].min().item() >= 0)
						self.assertTrue(encoding["labels"].max().item() <= 150)

						__UpperCAmelCase	: Dict		=					True
						__UpperCAmelCase	: List[Any]		=					image_processing(UpperCamelCase_      ,  UpperCamelCase_      ,  return_tensors="pt")
						self.assertTrue(encoding["labels"].min().item() >= 0)
						self.assertTrue(encoding["labels"].max().item() <= 255)










"""simple docstring"""





import argparse

import torch
from datasets import load_dataset
from donut import DonutModel

from transformers import (
    DonutImageProcessor,
    DonutProcessor,
    DonutSwinConfig,
    DonutSwinModel,
    MBartConfig,
    MBartForCausalLM,
    VisionEncoderDecoderModel,
    XLMRobertaTokenizerFast,
)

def 					_UpperCamelCase    (			UpperCamelCase							)			->			Tuple:


			"""simple docstring"""
			__UpperCAmelCase	: str		=					model.config

			__UpperCAmelCase	: int		=					DonutSwinConfig(
			    image_size=original_config.input_size				,       patch_size=4				,       depths=original_config.encoder_layer				,       num_heads=[4, 8, 16, 32]				,       window_size=original_config.window_size				,       embed_dim=128				,       )
			__UpperCAmelCase	: Union[str, Any]		=					MBartConfig(
			    is_decoder=UpperCamelCase				,       is_encoder_decoder=UpperCamelCase				,       add_cross_attention=UpperCamelCase				,       decoder_layers=original_config.decoder_layer				,       max_position_embeddings=original_config.max_position_embeddings				,       vocab_size=len(
			        model.decoder.tokenizer							)				,       scale_embedding=UpperCamelCase				,       add_final_layer_norm=UpperCamelCase				,       )

			return encoder_config, decoder_config

def 					_UpperCamelCase    (			UpperCamelCase							)			->			Union[str, Any]:


			"""simple docstring"""
			if "encoder.model" in name:
						__UpperCAmelCase	: Union[str, Any]		=					name.replace("encoder.model"				,       "encoder"							)
			if "decoder.model" in name:
						__UpperCAmelCase	: Dict		=					name.replace("decoder.model"				,       "decoder"							)
			if "patch_embed.proj" in name:
						__UpperCAmelCase	: Dict		=					name.replace("patch_embed.proj"				,       "embeddings.patch_embeddings.projection"							)
			if "patch_embed.norm" in name:
						__UpperCAmelCase	: str		=					name.replace("patch_embed.norm"				,       "embeddings.norm"							)
			if name.startswith("encoder"							):
						if "layers" in name:
									__UpperCAmelCase	: Dict		=					"encoder." + name
						if "attn.proj" in name:
									__UpperCAmelCase	: List[Any]		=					name.replace("attn.proj"				,       "attention.output.dense"							)
						if "attn" in name and "mask" not in name:
									__UpperCAmelCase	: int		=					name.replace("attn"				,       "attention.self"							)
						if "norm1" in name:
									__UpperCAmelCase	: Optional[Any]		=					name.replace("norm1"				,       "layernorm_before"							)
						if "norm2" in name:
									__UpperCAmelCase	: str		=					name.replace("norm2"				,       "layernorm_after"							)
						if "mlp.fc1" in name:
									__UpperCAmelCase	: str		=					name.replace("mlp.fc1"				,       "intermediate.dense"							)
						if "mlp.fc2" in name:
									__UpperCAmelCase	: Union[str, Any]		=					name.replace("mlp.fc2"				,       "output.dense"							)

						if name == "encoder.norm.weight":
									__UpperCAmelCase	: List[Any]		=					"encoder.layernorm.weight"
						if name == "encoder.norm.bias":
									__UpperCAmelCase	: Tuple		=					"encoder.layernorm.bias"

			return name

def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase							)			->			List[Any]:


			"""simple docstring"""
			for key in orig_state_dict.copy().keys():
						__UpperCAmelCase	: Any		=					orig_state_dict.pop(UpperCamelCase							)

						if "qkv" in key:
									__UpperCAmelCase	: Any		=					key.split("."							)
									__UpperCAmelCase	: List[Any]		=					int(key_split[3]							)
									__UpperCAmelCase	: Any		=					int(key_split[5]							)
									__UpperCAmelCase	: str		=					model.encoder.encoder.layers[layer_num].blocks[block_num].attention.self.all_head_size

									if "weight" in key:
												__UpperCAmelCase	: List[Any]		=					val[:dim, :]
												__UpperCAmelCase	: Union[str, Any]		=					val[dim : dim * 2, :]
												__UpperCAmelCase	: Any		=					val[-dim:, :]
									else:
												__UpperCAmelCase	: List[str]		=					val[:dim]
												__UpperCAmelCase	: List[Any]		=					val[dim : dim * 2]
												__UpperCAmelCase	: Tuple		=					val[-dim:]
						elif "attn_mask" in key or key in ["encoder.model.norm.weight", "encoder.model.norm.bias"]:
									# HuggingFace implementation doesn't use attn_mask buffer
									# and model doesn't use final LayerNorms for the encoder
									pass
						else:
									__UpperCAmelCase	: Dict		=					val

			return orig_state_dict

def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase=None				,       UpperCamelCase=False							)			->			List[str]:


			"""simple docstring"""
			# load original model
			__UpperCAmelCase	: Dict		=					DonutModel.from_pretrained(UpperCamelCase							).eval()

			# load HuggingFace model
			__UpperCAmelCase	,     __UpperCAmelCase	: List[str]		=					get_configs(UpperCamelCase							)
			__UpperCAmelCase	: Tuple		=					DonutSwinModel(UpperCamelCase							)
			__UpperCAmelCase	: Optional[Any]		=					MBartForCausalLM(UpperCamelCase							)
			__UpperCAmelCase	: int		=					VisionEncoderDecoderModel(encoder=UpperCamelCase				,       decoder=UpperCamelCase							)
			model.eval()

			__UpperCAmelCase	: Union[str, Any]		=					original_model.state_dict()
			__UpperCAmelCase	: List[str]		=					convert_state_dict(UpperCamelCase				,       UpperCamelCase							)
			model.load_state_dict(UpperCamelCase							)

			# verify results on scanned document
			__UpperCAmelCase	: List[Any]		=					load_dataset("hf-internal-testing/example-documents"							)
			__UpperCAmelCase	: Any		=					dataset["test"][0]["image"].convert("RGB"							)

			__UpperCAmelCase	: Union[str, Any]		=					XLMRobertaTokenizerFast.from_pretrained(UpperCamelCase				,       from_slow=UpperCamelCase							)
			__UpperCAmelCase	: str		=					DonutImageProcessor(
			    do_align_long_axis=original_model.config.align_long_axis				,       size=original_model.config.input_size[::-1]							)
			__UpperCAmelCase	: Union[str, Any]		=					DonutProcessor(UpperCamelCase				,       UpperCamelCase							)
			__UpperCAmelCase	: Union[str, Any]		=					processor(UpperCamelCase				,       return_tensors="pt"							).pixel_values

			if model_name == "naver-clova-ix/donut-base-finetuned-docvqa":
						__UpperCAmelCase	: List[Any]		=					"<s_docvqa><s_question>{user_input}</s_question><s_answer>"
						__UpperCAmelCase	: Any		=					"When is the coffee break?"
						__UpperCAmelCase	: Dict		=					task_prompt.replace("{user_input}"				,       UpperCamelCase							)
			elif model_name == "naver-clova-ix/donut-base-finetuned-rvlcdip":
						__UpperCAmelCase	: int		=					"<s_rvlcdip>"
			elif model_name in [
			    "naver-clova-ix/donut-base-finetuned-cord-v1",
			    "naver-clova-ix/donut-base-finetuned-cord-v1-2560",
			]:
						__UpperCAmelCase	: Union[str, Any]		=					"<s_cord>"
			elif model_name == "naver-clova-ix/donut-base-finetuned-cord-v2":
						__UpperCAmelCase	: Dict		=					"s_cord-v2>"
			elif model_name == "naver-clova-ix/donut-base-finetuned-zhtrainticket":
						__UpperCAmelCase	: str		=					"<s_zhtrainticket>"
			elif model_name in ["naver-clova-ix/donut-proto", "naver-clova-ix/donut-base"]:
						# use a random prompt
						__UpperCAmelCase	: Tuple		=					"hello world"
			else:
						raise ValueError("Model name not supported"							)
			__UpperCAmelCase	: Dict		=					original_model.decoder.tokenizer(UpperCamelCase				,       add_special_tokens=UpperCamelCase				,       return_tensors="pt"							)[
			    "input_ids"
			]

			__UpperCAmelCase	: int		=					original_model.encoder.model.patch_embed(UpperCamelCase							)
			__UpperCAmelCase	,     __UpperCAmelCase	: Tuple		=					model.encoder.embeddings(UpperCamelCase							)
			assert torch.allclose(UpperCamelCase				,       UpperCamelCase				,       atol=1e-3							)

			# verify encoder hidden states
			__UpperCAmelCase	: int		=					original_model.encoder(UpperCamelCase							)
			__UpperCAmelCase	: Union[str, Any]		=					model.encoder(UpperCamelCase							).last_hidden_state
			assert torch.allclose(UpperCamelCase				,       UpperCamelCase				,       atol=1e-2							)

			# verify decoder hidden states
			__UpperCAmelCase	: int		=					original_model(UpperCamelCase				,       UpperCamelCase				,       UpperCamelCase							).logits
			__UpperCAmelCase	: List[str]		=					model(UpperCamelCase				,       decoder_input_ids=UpperCamelCase							).logits
			assert torch.allclose(UpperCamelCase				,       UpperCamelCase				,       atol=1e-3							)
			print("Looks ok!"							)

			if pytorch_dump_folder_path is not None:
						print(f"Saving model and processor to {pytorch_dump_folder_path}"							)
						model.save_pretrained(UpperCamelCase							)
						processor.save_pretrained(UpperCamelCase							)

			if push_to_hub:
						model.push_to_hub("nielsr/" + model_name.split("/"							)[-1]				,       commit_message="Update model"							)
						processor.push_to_hub("nielsr/" + model_name.split("/"							)[-1]				,       commit_message="Update model"							)


if __name__ == "__main__":
					A   =       argparse.ArgumentParser()
					# Required parameters
					parser.add_argument(
					    """--model_name""",
					    default="""naver-clova-ix/donut-base-finetuned-docvqa""",
					    required=False,
					    type=str,
					    help="""Name of the original model you'd like to convert.""",
					)
					parser.add_argument(
					    """--pytorch_dump_folder_path""",
					    default=None,
					    required=False,
					    type=str,
					    help="""Path to the output PyTorch model directory.""",
					)
					parser.add_argument(
					    """--push_to_hub""",
					    action="""store_true""",
					    help="""Whether or not to push the converted model and processor to the 🤗 hub.""",
					)

					A   =       parser.parse_args()
					convert_donut_checkpoint(args.model_name, args.pytorch_dump_folder_path, args.push_to_hub)


