
'''simple docstring'''




from __future__ import annotations

lowerCAmelCase__          =						10







def       __UpperCAmelCase						(  lowerCamelCase_)							->     list[int]:
		UpperCamelCase__				:					Optional[int]					=					1
		UpperCamelCase__				:					Any					=					max(lowerCamelCase_)
		while placement <= max_digit:
				# declare and initialize empty buckets
				UpperCamelCase__				:					list[list]					=					[[] for _ in range(lowerCamelCase_)]
				# split list_of_ints between the buckets
				for i in list_of_ints:
						UpperCamelCase__				:					Any					=					int((i / placement) % RADIX)
						buckets[tmp].append(lowerCamelCase_)
				# put each buckets' contents into list_of_ints
				UpperCamelCase__				:					int					=					0
				for b in range(lowerCamelCase_):
						for i in buckets[b]:
								UpperCamelCase__				:					int					=					i
								a += 1
        # move to next
				placement *= RADIX
		return list_of_ints


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)




