'''simple docstring'''




import importlib.metadata
import subprocess
import sys


def  lowerCamelCase__						(  SCREAMING_SNAKE_CASE :				bool = False  ):
  UpperCAmelCase  							=		False
  if "IPython" in sys.modules:
    UpperCAmelCase  							=		'google.colab' in str(sys.modules['IPython'].get_ipython()  )

  if in_colab:
    if upgrade:
      UpperCAmelCase  							=		['pip', 'install', '-U', 'torch']
      subprocess.run(SCREAMING_SNAKE_CASE    ,				check=SCREAMING_SNAKE_CASE  )
    # get the current version of torch
    UpperCAmelCase  							=		importlib.metadata.version('torch'  )
    UpperCAmelCase  							=		torch_version[: torch_version.rindex('.'  )]
    UpperCAmelCase  							=		f'''https://storage.googleapis.com/tpu-pytorch/wheels/colab/torch_xla-{torch_version_trunc}-cp37-cp37m-linux_x86_64.whl'''
    UpperCAmelCase  							=		['pip', 'install', xla_wheel]
    subprocess.run(SCREAMING_SNAKE_CASE    ,				check=SCREAMING_SNAKE_CASE  )
  else:
    raise RuntimeError('`install_xla` utility works only on google colab.'  )





'''simple docstring'''




def  lowerCamelCase__						(  SCREAMING_SNAKE_CASE :				str  ):
  UpperCAmelCase  							=		str(SCREAMING_SNAKE_CASE  ).strip()
  if not bin_string:
    raise ValueError('Empty string was passed to the function'  )
  UpperCAmelCase  							=		bin_string[0] == '-'
  if is_negative:
    UpperCAmelCase  							=		bin_string[1:]
  if not all(char in '01' for char in bin_string  ):
    raise ValueError('Non-binary value was passed to the function'  )
  UpperCAmelCase  							=		0
  for char in bin_string:
    UpperCAmelCase  							=		2 * decimal_number + int(SCREAMING_SNAKE_CASE  )
  return -decimal_number if is_negative else decimal_number


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

  testmod()


