




from math import factorial







def 				lowerCAmelCase_	(     snake_case_,snake_case_,snake_case_     ):
      if successes > trials:
            raise ValueError("""successes must be lower or equal to trials"""     )
      if trials < 0 or successes < 0:
            raise ValueError("""the function is defined for non-negative integers"""     )
      if not isinstance(snake_case_,snake_case_     ) or not isinstance(snake_case_,snake_case_     ):
            raise ValueError("""the function is defined for non-negative integers"""     )
      if not 0 < prob < 1:
            raise ValueError("""prob has to be in range of 1 - 0"""     )
      _A							:     Union[str, Any]			=						(prob**successes) * ((1 - prob) ** (trials - successes))
      # Calculate the binomial coefficient: n! / k!(n-k)!
      _A							:     Any			=						float(factorial(snake_case_     )     )
      coefficient /= factorial(snake_case_     ) * factorial(trials - successes     )
      return probability * coefficient


if __name__ == "__main__":
  from doctest import testmod

  testmod()
  print("Probability of 2 successes out of 4 trails")
  print("with probability of 0.75 is:", end=" ")
  print(binomial_distribution(2, 4, 0.7_5))




from typing import Union

import fire
import torch
from tqdm import tqdm
def 						_snake_case(    SCREAMING_SNAKE_CASE__			:	str    ,			SCREAMING_SNAKE_CASE__			:	str = "cpu"    ,			SCREAMING_SNAKE_CASE__			:	Union[str, None] = None      )							->      None:





    '''simple docstring'''






    A__          =   torch.load(SCREAMING_SNAKE_CASE__    ,			map_location=SCREAMING_SNAKE_CASE__      )
    for k, v in tqdm(state_dict.items()      ):
        if not isinstance(SCREAMING_SNAKE_CASE__    ,			torch.Tensor      ):
            raise TypeError('FP16 conversion only works on paths that are saved state dicts, like pytorch_model.bin'      )
        A__          =   v.half()
    if save_path is None:  # overwrite src_path
        A__          =   src_path
    torch.save(SCREAMING_SNAKE_CASE__    ,			SCREAMING_SNAKE_CASE__      )


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

