



import importlib.metadata
import subprocess
import sys







def  _UpperCAmelCase  (				SCREAMING_SNAKE_CASE__ = False  ):


						'''simple docstring'''




						lowerCAmelCase	:   Optional[Any]					     =					False
						if "IPython" in sys.modules:
												lowerCAmelCase	:   Optional[Any]					     =					"""google.colab""" in str(sys.modules["""IPython"""].get_ipython()  )

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






def  _UpperCAmelCase  (				SCREAMING_SNAKE_CASE__  ):


						'''simple docstring'''




						lowerCAmelCase	:   List[str]					     =					str(SCREAMING_SNAKE_CASE__  ).strip()
						if not bin_string:
												raise ValueError("""Empty string was passed to the function"""  )
						lowerCAmelCase	:   Optional[int]					     =					bin_string[0] == """-"""
						if is_negative:
												lowerCAmelCase	:   Tuple					     =					bin_string[1:]
						if not all(char in """01""" for char in bin_string  ):
												raise ValueError("""Non-binary value was passed to the function"""  )
						lowerCAmelCase	:   Union[str, Any]					     =					0
						for char in bin_string:
												lowerCAmelCase	:   int					     =					2 * decimal_number + int(SCREAMING_SNAKE_CASE__  )
						return -decimal_number if is_negative else decimal_number


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

		testmod()

