




"""simple docstring"""




import os
import sys
from contextlib import contextmanager


# Windows only
if os.name == "nt":
					import ctypes
					import msvcrt  # noqa






					class     __magic_name__							(       ctypes.Structure				):






									'''simple docstring'''
									__UpperCamelCase			  =						[("size", ctypes.c_int), ("visible", ctypes.c_byte)]



def     a__ (				)						->					Optional[int]:






			if os.name == "nt":
						lowerCamelCase			      =					CursorInfo()
						lowerCamelCase			      =					ctypes.windll.kernelaa.GetStdHandle(-11				)
						ctypes.windll.kernelaa.GetConsoleCursorInfo(SCREAMING_SNAKE_CASE__       , ctypes.byref(SCREAMING_SNAKE_CASE__				)				)
						lowerCamelCase			      =					False
						ctypes.windll.kernelaa.SetConsoleCursorInfo(SCREAMING_SNAKE_CASE__       , ctypes.byref(SCREAMING_SNAKE_CASE__				)				)
			elif os.name == "posix":
						sys.stdout.write("""\033[?25l"""				)
						sys.stdout.flush()



def     a__ (				)						->					Optional[int]:






			if os.name == "nt":
						lowerCamelCase			      =					CursorInfo()
						lowerCamelCase			      =					ctypes.windll.kernelaa.GetStdHandle(-11				)
						ctypes.windll.kernelaa.GetConsoleCursorInfo(SCREAMING_SNAKE_CASE__       , ctypes.byref(SCREAMING_SNAKE_CASE__				)				)
						lowerCamelCase			      =					True
						ctypes.windll.kernelaa.SetConsoleCursorInfo(SCREAMING_SNAKE_CASE__       , ctypes.byref(SCREAMING_SNAKE_CASE__				)				)
			elif os.name == "posix":
						sys.stdout.write("""\033[?25h"""				)
						sys.stdout.flush()



@contextmanager
def     a__ (				)						->					Union[str, Any]:






			try:
						hide_cursor()
						yield
			finally:
						show_cursor()






from typing import Union

import fire
import torch
from tqdm import tqdm
def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	str    ,			SCREAMING_SNAKE_CASE__			:	str = "cpu"    ,			SCREAMING_SNAKE_CASE__			:	Union[str, None] = None      )							->      None:





    '''simple docstring'''






    A__          =   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__          =   v.half()
    if save_path is None:  # overwrite src_path
        A__          =   src_path
    torch.save(SCREAMING_SNAKE_CASE__    ,			SCREAMING_SNAKE_CASE__      )


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

