


'''simple docstring'''






import warnings
from functools import wraps
from typing import Callable







def 							UpperCamelCase_     (       A__   :  Callable   ):
  '''simple docstring'''





  @wraps(A__   )
  def _inner_fn(*A__   :  List[Any]				,       **A__   :  Dict   ):
    warnings.warn(
        (f'\'{fn.__name__}\' is experimental and might be subject to breaking changes in the future.')				,       A__				,       )
    return fn(*A__				,       **A__   )

  return _inner_fn







'''simple docstring'''






from typing import Union

import fire
import torch
from tqdm import tqdm







def 							UpperCamelCase_     (       A__   :  str				,       A__   :  str = "cpu"				,       A__   :  Union[str, None] = None   ):
  '''simple docstring'''





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


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



