
'''simple docstring'''




from __future__ import annotations







def       __UpperCAmelCase						(  lowerCamelCase_     ,      lowerCamelCase_     ,      lowerCamelCase_     ,      lowerCamelCase_)							->     str:  # noqa: E741
		while r - l > 1:
				UpperCamelCase__				:					List[str]					=					(l + r) // 2
				if v[m] >= key:
						UpperCamelCase__				:					Dict					=					m
				else:
						UpperCamelCase__				:					Any					=					m  # noqa: E741
		return r







def       __UpperCAmelCase						(  lowerCamelCase_)							->     List[str]:
		if len(lowerCamelCase_) == 0:
				return 0

		UpperCamelCase__				:					Optional[int]					=					[0] * len(lowerCamelCase_)
		UpperCamelCase__				:					Dict					=					1

		UpperCamelCase__				:					Dict					=					v[0]

		for i in range(1     ,      len(lowerCamelCase_)):
				if v[i] < tail[0]:
						UpperCamelCase__				:					Tuple					=					v[i]
				elif v[i] > tail[length - 1]:
						UpperCamelCase__				:					Dict					=					v[i]
						length += 1
				else:
						UpperCamelCase__				:					Optional[int]					=					v[i]

		return length


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)




