





from typing import Union

import fire
import torch
from tqdm import tqdm
def      _A       (		SCREAMING_SNAKE_CASE     :   str       ,       SCREAMING_SNAKE_CASE     :   str = "cpu"       ,       SCREAMING_SNAKE_CASE     :   Union[str, None] = None						):





  """simple docstring"""



  a__	:					int										=torch.load(SCREAMING_SNAKE_CASE       ,       map_location=SCREAMING_SNAKE_CASE						)
  for k, v in tqdm(state_dict.items()						):
    if not isinstance(SCREAMING_SNAKE_CASE       ,       torch.Tensor						):
      raise TypeError("FP16 conversion only works on paths that are saved state dicts, like pytorch_model.bin"						)
    a__	:					Tuple										=v.half()
  if save_path is None:  # overwrite src_path
    a__	:					Optional[int]										=src_path
  torch.save(SCREAMING_SNAKE_CASE       ,       SCREAMING_SNAKE_CASE						)


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













from diffusers.utils.testing_utils import require_onnxruntime







@require_onnxruntime
class 				__lowerCAmelCase       :
      pass






