






'''simple docstring'''




import warnings

from ...utils import logging
from .image_processing_donut import DonutImageProcessor


lowerCAmelCase__          =						logging.get_logger(__name__)







class       __lowercase					(__lowerCamelCase    ):

	def __init__(      self   :						List[str]  ,					*UpperCAmelCase_   :						Optional[int]  ,					**UpperCAmelCase_   :						str):
			warnings.warn(
			    'The class DonutFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please'
			    ' use DonutImageProcessor instead.'  ,					UpperCAmelCase_  ,					)
			super().__init__(*UpperCAmelCase_  ,					**UpperCAmelCase_)












'''simple docstring'''




from typing import Union

import fire
import torch
from tqdm import tqdm







def       __UpperCAmelCase						(  lowerCamelCase_     ,      lowerCamelCase_ = "cpu"     ,      lowerCamelCase_ = None)							->     None:
		UpperCamelCase__				:					List[Any]					=					torch.load(lowerCamelCase_     ,      map_location=lowerCamelCase_)
		for k, v in tqdm(state_dict.items()):
				if not isinstance(lowerCamelCase_     ,      torch.Tensor):
						raise TypeError('FP16 conversion only works on paths that are saved state dicts, like pytorch_model.bin')
				UpperCamelCase__				:					int					=					v.half()
		if save_path is None:  # overwrite src_path
				UpperCamelCase__				:					List[Any]					=					src_path
		torch.save(lowerCamelCase_     ,      lowerCamelCase_)


if __name__ == "__main__":
		fire.Fire(convert)




