






"""simple docstring"""





from typing import TYPE_CHECKING

from ..utils import _LazyModule


__lowerCamelCase							=  {
    'config': [
        'EXTERNAL_DATA_FORMAT_SIZE_LIMIT',
        'OnnxConfig',
        'OnnxConfigWithPast',
        'OnnxSeq2SeqConfigWithPast',
        'PatchingSpec',
    ],
    'convert': ['export', 'validate_model_outputs'],
    'features': ['FeaturesManager'],
    'utils': ['ParameterFormat', 'compute_serialized_parameters_size'],
}


if TYPE_CHECKING:
							from .config import (
							    EXTERNAL_DATA_FORMAT_SIZE_LIMIT,
							    OnnxConfig,
							    OnnxConfigWithPast,
							    OnnxSeqaSeqConfigWithPast,
							    PatchingSpec,
							)
							from .convert import export, validate_model_outputs
							from .features import FeaturesManager
							from .utils import ParameterFormat, compute_serialized_parameters_size

else:
							import sys

							__lowerCamelCase							=  _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)











"""simple docstring"""





from typing import Union

import fire
import torch
from tqdm import tqdm



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


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



