


"""simple docstring"""







import inspect
import os
import unittest

import torch

import accelerate
from accelerate import debug_launcher
from accelerate.test_utils import (
    execute_subprocess_async,
    require_cpu,
    require_multi_gpu,
    require_single_gpu,
    test_sync,
)
from accelerate.utils import patch_environment
class 				lowerCamelCase							(      unittest.TestCase			):


							"""simple docstring"""






							def        lowerCAmelCase  (    self			:  Any					):
													UpperCAmelCase__												=     inspect.getfile(accelerate.test_utils					)
													UpperCAmelCase__												=     os.path.sep.join(mod_file.split(os.path.sep					)[:-1] + ['''scripts''', '''test_sync.py''']					)






							@require_cpu
							def        lowerCAmelCase  (    self			:  Tuple					):
													debug_launcher(test_sync.main		,			num_processes=1					)






							@require_cpu
							def        lowerCAmelCase  (    self			:  int					):
													debug_launcher(test_sync.main					)






							@require_single_gpu
							def        lowerCAmelCase  (    self			:  int					):
													test_sync.main()






							@require_multi_gpu
							def        lowerCAmelCase  (    self			:  Any					):
													print(f"""Found {torch.cuda.device_count()} devices."""					)
													UpperCAmelCase__												=     ['''torchrun''', f"""--nproc_per_node={torch.cuda.device_count()}""", self.test_file_path]
													with patch_environment(omp_num_threads=1					):
																			execute_subprocess_async(lowerCamelCase_		,			env=os.environ.copy()					)



"""simple docstring"""







from __future__ import annotations






def        a__			(							_UpperCamelCase			):





						"""simple docstring"""

						UpperCAmelCase__												=     sorted(_UpperCamelCase			)
						UpperCAmelCase__												=     len(_UpperCamelCase			)
						UpperCAmelCase__												=     length >> 1
						return (
						    (sorted_list[mid_index] + sorted_list[mid_index - 1]) / 2
						    if length % 2 == 0
						    else sorted_list[mid_index]
						)






def        a__			(							):





						"""simple docstring"""

						import doctest

						doctest.testmod()


if __name__ == "__main__":
						main()