






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 	lowercase_      (			unittest.TestCase     ):






      '''simple docstring'''




      def    __lowerCAmelCase      (   self   :		List[str]						)					->str:




       """simple docstring"""


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







      @require_cpu
      def    __lowerCAmelCase      (   self   :		str						)					->str:




       """simple docstring"""


       debug_launcher(test_sync.main				,      num_processes=1						)







      @require_cpu
      def    __lowerCAmelCase      (   self   :		Optional[int]						)					->str:




       """simple docstring"""


       debug_launcher(test_sync.main						)







      @require_single_gpu
      def    __lowerCAmelCase      (   self   :		Any						)					->List[Any]:




       """simple docstring"""


       test_sync.main()







      @require_multi_gpu
      def    __lowerCAmelCase      (   self   :		Optional[int]						)					->Optional[Any]:




       """simple docstring"""


       print(F"""Found {torch.cuda.device_count()} devices."""						)
       a							=   ['''torchrun''', F"""--nproc_per_node={torch.cuda.device_count()}""", self.test_file_path]
       with patch_environment(omp_num_threads=1						):
        execute_subprocess_async(__snake_case				,      env=os.environ.copy()						)










from collections import namedtuple

UpperCAmelCase__            =	namedtuple("from_to", "from_ to")

UpperCAmelCase__            =	{
    "atm": from_to(1, 1),
    "pascal": from_to(0.000_0098, 101325),
    "bar": from_to(0.98_6923, 1.0_1325),
    "kilopascal": from_to(0.0098_6923, 101.325),
    "megapascal": from_to(9.8_6923, 0.10_1325),
    "psi": from_to(0.06_8046, 14.6959),
    "inHg": from_to(0.033_4211, 29.9213),
    "torr": from_to(0.0013_1579, 760),
}
def 		_a					(   a				:float			,							a				:str			,							a				:str				)							->    float:
 if from_type not in PRESSURE_CONVERSION:
  raise ValueError(
      F"""Invalid 'from_type' value: {from_type!r}  Supported values are:\n"""
      + ''', '''.join(a				)				)
 if to_type not in PRESSURE_CONVERSION:
  raise ValueError(
      F"""Invalid 'to_type' value: {to_type!r}.  Supported values are:\n"""
      + ''', '''.join(a				)				)
 return (
     value * PRESSURE_CONVERSION[from_type].from_ * PRESSURE_CONVERSION[to_type].to
 )


if __name__ == "__main__":
     import doctest

     doctest.testmod()


