




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


   """simple docstring"""

   def 							lowerCAmelCase_			(    self					:	Dict    ):

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



   @require_cpu
   def 							lowerCAmelCase_			(    self					:	int    ):

      """simple docstring"""
      debug_launcher(test_sync.main  ,      num_processes=1    )



   @require_cpu
   def 							lowerCAmelCase_			(    self					:	Optional[int]    ):

      """simple docstring"""
      debug_launcher(test_sync.main    )



   @require_single_gpu
   def 							lowerCAmelCase_			(    self					:	Union[str, Any]    ):

      """simple docstring"""
      test_sync.main()



   @require_multi_gpu
   def 							lowerCAmelCase_			(    self					:	Dict    ):

      """simple docstring"""
      print(F"""Found {torch.cuda.device_count()} devices."""    )
      _SCREAMING_SNAKE_CASE       =      ["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()    )








"""simple docstring"""
import os
import sys
import time

from . import transposition_cipher as trans_cipher

def 						_SCREAMING_SNAKE_CASE       ():
 lowerCAmelCase  							=      'Prehistoric Men.txt'
 lowerCAmelCase  							=      'Output.txt'
 lowerCAmelCase  							=      int(input('Enter key: '       )       )
 lowerCAmelCase  							=      input('Encrypt/Decrypt [e/d]: '       )

 if not os.path.exists(_UpperCAmelCase       ):
  print(F'File {input_file} does not exist. Quitting...'       )
  sys.exit()
 if os.path.exists(_UpperCAmelCase       ):
  print(F'Overwrite {output_file}? [y/n]'       )
  lowerCAmelCase  							=      input('> '       )
  if not response.lower().startswith('y'       ):
   sys.exit()

 lowerCAmelCase  							=      time.time()
 if mode.lower().startswith('e'       ):
  with open(_UpperCAmelCase       ) as f:
   lowerCAmelCase  							=      f.read()
  lowerCAmelCase  							=      trans_cipher.encrypt_message(_UpperCAmelCase   ,			_UpperCAmelCase       )
 elif mode.lower().startswith('d'       ):
  with open(_UpperCAmelCase       ) as f:
   lowerCAmelCase  							=      f.read()
  lowerCAmelCase  							=      trans_cipher.decrypt_message(_UpperCAmelCase   ,			_UpperCAmelCase       )

 with open(_UpperCAmelCase   ,			'w'       ) as output_obj:
  output_obj.write(_UpperCAmelCase       )

 lowerCAmelCase  							=      round(time.time() - start_time   ,			2       )
 print(('Done (', total_time, 'seconds )')       )


if __name__ == "__main__":
       main()





