






'''simple docstring'''




def       __UpperCAmelCase						(  lowerCamelCase_     ,      lowerCamelCase_)							->     str:
		if a < 0 or b < 0:
				raise ValueError('the value of both inputs must be positive')
		UpperCamelCase__				:					Tuple					=					str(bin(lowerCamelCase_))[2:]  # remove the leading "0b"
		UpperCamelCase__				:					str					=					str(bin(lowerCamelCase_))[2:]
		UpperCamelCase__				:					List[str]					=					max(len(lowerCamelCase_)     ,      len(lowerCamelCase_))
		return "0b" + "".join(
		    str(int('1' in (char_a, char_b)))
		    for char_a, char_b in zip(a_binary.zfill(lowerCamelCase_)     ,      b_binary.zfill(lowerCamelCase_)))


if __name__ == "__main__":
		import doctest

		doctest.testmod()












'''simple docstring'''




from typing import Union

import fire
import torch
from tqdm import tqdm







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


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




