


'''simple docstring'''







# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse

from ...utils.dataclasses import (
    ComputeEnvironment,
    DistributedType,
    DynamoBackend,
    PrecisionType,
    SageMakerDistributedType,
)
from ..menu import BulletMenu


lowerCAmelCase    :     int					=						[
    """EAGER""",
    """AOT_EAGER""",
    """INDUCTOR""",
    """NVFUSER""",
    """AOT_NVFUSER""",
    """AOT_CUDAGRAPHS""",
    """OFI""",
    """FX2TRT""",
    """ONNXRT""",
    """IPEX""",
]






def 			lowercase				(_A   ,						_A=None   ,						_A=None   ,						_A=None					):







       """simple docstring"""







       _lowerCAmelCase    :							Optional[Any]   			=       True
       while ask_again:
              _lowerCAmelCase    :							Dict   			=       input(_A					)
              try:
                     if default is not None and len(_A					) == 0:
                            return default
                     return convert_value(_A					) if convert_value is not None else result
              except Exception:
                     if error_message is not None:
                            print(_A					)






def 			lowercase				(_A   ,						_A=[]   ,						_A=None   ,						_A=0					):







       """simple docstring"""







       _lowerCAmelCase    :							Dict   			=       BulletMenu(_A   ,						_A					)
       _lowerCAmelCase    :							Optional[int]   			=       menu.run(default_choice=_A					)
       return convert_value(_A					) if convert_value is not None else result






def 			lowercase				(_A					):







       """simple docstring"""







       _lowerCAmelCase    :							Optional[int]   			=       int(_A					)
       return ComputeEnvironment(['LOCAL_MACHINE', 'AMAZON_SAGEMAKER'][value]					)






def 			lowercase				(_A					):







       """simple docstring"""







       _lowerCAmelCase    :							str   			=       int(_A					)
       return DistributedType(['NO', 'MULTI_CPU', 'MULTI_XPU', 'MULTI_GPU', 'MULTI_NPU', 'TPU'][value]					)






def 			lowercase				(_A					):







       """simple docstring"""







       _lowerCAmelCase    :							Optional[int]   			=       int(_A					)
       return DynamoBackend(DYNAMO_BACKENDS[value]					).value






def 			lowercase				(_A					):







       """simple docstring"""







       _lowerCAmelCase    :							Optional[int]   			=       int(_A					)
       return PrecisionType(['no', 'fp16', 'bf16', 'fp8'][value]					)






def 			lowercase				(_A					):







       """simple docstring"""







       _lowerCAmelCase    :							Union[str, Any]   			=       int(_A					)
       return SageMakerDistributedType(['NO', 'DATA_PARALLEL', 'MODEL_PARALLEL'][value]					)






def 			lowercase				(_A					):







       """simple docstring"""







       return {"yes": True, "no": False}[value.lower()]
class 	UpperCamelCase__					( argparse.RawDescriptionHelpFormatter	):



     """simple docstring"""






     def a	( self      ,	snake_case__      ,	snake_case__      ,	snake_case__      ,	snake_case__   ):

            '''simple docstring'''

            _lowerCAmelCase    :							List[str]   			=       super()._format_usage(snake_case__      ,	snake_case__      ,	snake_case__      ,	snake_case__   )
            _lowerCAmelCase    :							int   			=       usage.replace('<command> [<args>] '      ,	''   )
            return usage





'''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()

