





'''simple docstring'''


import importlib.metadata
import subprocess
import sys




def       A							(      _UpperCAmelCase   :				bool = False					)  ->				List[str]:


  '''simple docstring'''




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

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












'''simple docstring'''


from __future__ import annotations




def       A							(      _UpperCAmelCase   :				list					)  ->				int | float:


  '''simple docstring'''




  __lowerCAmelCase		:    List[Any]			     =  sorted(_UpperCAmelCase					)
  __lowerCAmelCase		:    List[str]			     =  len(_UpperCAmelCase					)
  __lowerCAmelCase		:    Any			     =  length >> 1
  return (
      (sorted_list[mid_index] + sorted_list[mid_index - 1]) / 2
      if length % 2 == 0
      else sorted_list[mid_index]
  )




def       A							(      )  ->				Union[str, Any]:


  '''simple docstring'''




  import doctest

  doctest.testmod()


if __name__ == "__main__":
    main()





