


'''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_huggingface_suite,
    require_multi_gpu,
    require_single_gpu,
)
from accelerate.utils import patch_environment
@require_huggingface_suite
class 	UpperCamelCase__					( unittest.TestCase	):



     """simple docstring"""






     def a	( self   ):

            '''simple docstring'''

            _lowerCAmelCase    :							Optional[int]   			=       inspect.getfile(accelerate.test_utils   )
            _lowerCAmelCase    :							Optional[Any]   			=       os.path.sep.join(
                mod_file.split(os.path.sep   )[:-1] + ['scripts', 'external_deps', 'test_metrics.py']   )

            from accelerate.test_utils.scripts.external_deps import test_metrics  # noqa: F401

            _lowerCAmelCase    :							Union[str, Any]   			=       test_metrics







     @require_cpu
     def a	( self   ):

            '''simple docstring'''

            debug_launcher(self.test_metrics.main      ,	num_processes=1   )







     @require_cpu
     def a	( self   ):

            '''simple docstring'''

            debug_launcher(self.test_metrics.main   )







     @require_single_gpu
     def a	( self   ):

            '''simple docstring'''

            self.test_metrics.main()







     @require_multi_gpu
     def a	( self   ):

            '''simple docstring'''

            print(F'Found {torch.cuda.device_count()} devices.'   )
            _lowerCAmelCase    :							str   			=       ['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 socket






def 			lowercase				():







       """simple docstring"""







       _lowerCAmelCase    :							Tuple   			=       socket.socket(socket.AF_INET   ,						socket.SOCK_STREAM					)
       _lowerCAmelCase    :							Optional[int]   			=       socket.gethostname()
       _lowerCAmelCase    :							Any   			=       1_2_3_1_2

       sock.connect((host, port)					)
       sock.send(B'Hello server!'					)

       with open('Received_file'   ,						'wb'					) as out_file:
              print('File opened'					)
              print('Receiving data...'					)
              while True:
                     _lowerCAmelCase    :							Union[str, Any]   			=       sock.recv(1_0_2_4					)
                     if not data:
                            break
                     out_file.write(_A					)

       print('Successfully received the file'					)
       sock.close()
       print('Connection closed'					)


if __name__ == "__main__":
       main()

