




def 					UpperCAmelCase__     (   lowerCamelCase,	lowerCamelCase      ):

  # Check if the input is valid
  if not len(lowerCamelCase      ) == len(lowerCamelCase      ) == 3:
    raise ValueError("Please enter a valid equation."      )
  if equationa[0] == equationa[1] == equationa[0] == equationa[1] == 0:
    raise ValueError("Both a & b of two equations can't be zero."      )

  # Extract the coefficients
  lowercase		,			lowercase		,			lowercase			:str							=  equationa
  lowercase		,			lowercase		,			lowercase			:int							=  equationa

  # Calculate the determinants of the matrices
  lowercase			:int							=  aa * ba - aa * ba
  lowercase			:int							=  ca * ba - ca * ba
  lowercase			:Union[str, Any]							=  aa * ca - aa * ca

  # Check if the system of linear equations has a solution (using Cramer's rule)
  if determinant == 0:
    if determinant_x == determinant_y == 0:
      raise ValueError("Infinite solutions. (Consistent system)"      )
    else:
      raise ValueError("No solution. (Inconsistent system)"      )
  else:
    if determinant_x == determinant_y == 0:
      # Trivial solution (Inconsistent system)
      return (0.0, 0.0)
    else:
      lowercase			:Optional[int]							=  determinant_x / determinant
      lowercase			:int							=  determinant_y / determinant
      # Non-Trivial Solution (Consistent system)
      return (x, y)









from typing import Union

import fire
import torch
from tqdm import tqdm



def 					UpperCAmelCase__     (   lowerCamelCase,	lowerCamelCase = "cpu",	lowerCamelCase = None      ):
  lowercase			:Optional[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"      )
    lowercase			:List[Any]							=  v.half()
  if save_path is None:  # overwrite src_path
    lowercase			:Optional[Any]							=  src_path
  torch.save(lowerCamelCase,	lowerCamelCase      )


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



