
"""simple docstring"""






from typing import Union

import fire
import torch
from tqdm import tqdm




def __magic_name__	(				_lowerCamelCase:		str,					_lowerCamelCase:		str = "cpu",					_lowerCamelCase:		Union[str, None] = None			)					->						None:

	'''simple docstring'''




	lowerCAmelCase												=  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'''			)
		lowerCAmelCase												=  v.half()
	if save_path is None:  # overwrite src_path
		lowerCAmelCase												=  src_path
	torch.save(_lowerCamelCase,					_lowerCamelCase			)


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




"""simple docstring"""






def __magic_name__	(				_lowerCamelCase:		Tuple,					_lowerCamelCase:		Any			)					->						Optional[Any]:

	'''simple docstring'''




	lowerCAmelCase												=  [1]
	for i in range(2,					_lowerCamelCase			):
		factorials.append(factorials[-1] * i			)
	assert 0 <= k < factorials[-1] * n, "k out of bounds"

	lowerCAmelCase												=  []
	lowerCAmelCase												=  list(range(_lowerCamelCase			)			)

	# Find permutation
	while factorials:
		lowerCAmelCase												=  factorials.pop()
		lowerCAmelCase							,       lowerCAmelCase												=  divmod(_lowerCamelCase,					_lowerCamelCase			)
		permutation.append(elements[number]			)
		elements.remove(elements[number]			)
	permutation.append(elements[0]			)

	return permutation


if __name__ == "__main__":
					import doctest

					doctest.testmod()


