
"""simple docstring"""


from typing import Union

import fire
import torch
from tqdm import tqdm



def 	lowerCamelCase__			(							UpperCAmelCase_		,      UpperCAmelCase_ = "cpu"		,      UpperCAmelCase_ = None				)->							None:







       """simple docstring"""
       UpperCamelCase					 =		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"				)
              UpperCamelCase					 =		v.half()
       if save_path is None:  # overwrite src_path
              UpperCamelCase					 =		src_path
       torch.save(UpperCAmelCase_		,      UpperCAmelCase_				)


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







"""simple docstring"""


def 	lowerCamelCase__			(							UpperCAmelCase_				)->							int:







       """simple docstring"""
       if a < 0:
              raise ValueError("Input value must be a positive integer"				)
       elif isinstance(UpperCAmelCase_		,      UpperCAmelCase_				):
              raise TypeError("Input value must be a 'int' type"				)
       return bin(UpperCAmelCase_				).count("1"				)


if __name__ == "__main__":
      import doctest

      doctest.testmod()





