"""simple docstring"""



import argparse

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


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



def 		lowercase (       UpperCamelCase     :     List[Any]       ,  UpperCamelCase     :     int=None       ,  UpperCamelCase     :     Any=None       ,  UpperCamelCase     :     Optional[Any]=None		):





      """simple docstring"""
      A__	:      Union[str, Any]      =True
      while ask_again:
            A__	:      List[str]      =input(UpperCamelCase		)
            try:
                  if default is not None and len(UpperCamelCase		) == 0:
                        return default
                  return convert_value(UpperCamelCase		) if convert_value is not None else result
            except Exception:
                  if error_message is not None:
                        print(UpperCamelCase		)



def 		lowercase (       UpperCamelCase     :     Union[str, Any]       ,  UpperCamelCase     :     Optional[int]=[]       ,  UpperCamelCase     :     List[Any]=None       ,  UpperCamelCase     :     Tuple=0		):





      """simple docstring"""
      A__	:      int      =BulletMenu(UpperCamelCase       ,  UpperCamelCase		)
      A__	:      int      =menu.run(default_choice=UpperCamelCase		)
      return convert_value(UpperCamelCase		) if convert_value is not None else result



def 		lowercase (       UpperCamelCase     :     Dict		):





      """simple docstring"""
      A__	:      Any      =int(UpperCamelCase		)
      return ComputeEnvironment(["LOCAL_MACHINE", "AMAZON_SAGEMAKER"][value]		)



def 		lowercase (       UpperCamelCase     :     int		):





      """simple docstring"""
      A__	:      Dict      =int(UpperCamelCase		)
      return DistributedType(["NO", "MULTI_CPU", "MULTI_XPU", "MULTI_GPU", "MULTI_NPU", "TPU"][value]		)



def 		lowercase (       UpperCamelCase     :     int		):





      """simple docstring"""
      A__	:      List[str]      =int(UpperCamelCase		)
      return DynamoBackend(DYNAMO_BACKENDS[value]		).value



def 		lowercase (       UpperCamelCase     :     Tuple		):





      """simple docstring"""
      A__	:      List[Any]      =int(UpperCamelCase		)
      return PrecisionType(["no", "fp16", "bf16", "fp8"][value]		)



def 		lowercase (       UpperCamelCase     :     Tuple		):





      """simple docstring"""
      A__	:      Any      =int(UpperCamelCase		)
      return SageMakerDistributedType(["NO", "DATA_PARALLEL", "MODEL_PARALLEL"][value]		)



def 		lowercase (       UpperCamelCase     :     Tuple		):





      """simple docstring"""
      return {"yes": True, "no": False}[value.lower()]






class 	__lowerCAmelCase					(      argparse.RawDescriptionHelpFormatter):




    '''simple docstring'''






    def 					_UpperCAmelCase		(     self				:	Tuple					,				UpperCamelCase__				:	int					,				UpperCamelCase__				:	int					,				UpperCamelCase__				:	str					,				UpperCamelCase__				:	List[Any]							):
          A__	:      Union[str, Any]      =super()._format_usage(lowerCamelCase_					,				lowerCamelCase_					,				lowerCamelCase_					,				lowerCamelCase_							)
          A__	:      Optional[int]      =usage.replace("<command> [<args>] "					,				""							)
          return usage









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


__UpperCAmelCase       							=				[
    '''EAGER''',
    '''AOT_EAGER''',
    '''INDUCTOR''',
    '''NVFUSER''',
    '''AOT_NVFUSER''',
    '''AOT_CUDAGRAPHS''',
    '''OFI''',
    '''FX2TRT''',
    '''ONNXRT''',
    '''IPEX''',
]


def    _snake_case  (	A					,       A=None					,       A=None					,       A=None			)		->       Union[str, Any]:
							lowerCAmelCase__			  =      True
							while ask_again:
														lowerCAmelCase__			  =      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    _snake_case  (	A					,       A=[]					,       A=None					,       A=0			)		->       List[Any]:
							lowerCAmelCase__			  =      BulletMenu(A					,       A			)
							lowerCAmelCase__			  =      menu.run(default_choice=A			)
							return convert_value(A			) if convert_value is not None else result


def    _snake_case  (	A			)		->       Tuple:
							lowerCAmelCase__			  =      int(A			)
							return ComputeEnvironment(['''LOCAL_MACHINE''', '''AMAZON_SAGEMAKER'''][value]			)


def    _snake_case  (	A			)		->       Union[str, Any]:
							lowerCAmelCase__			  =      int(A			)
							return DistributedType(['''NO''', '''MULTI_CPU''', '''MULTI_XPU''', '''MULTI_GPU''', '''MULTI_NPU''', '''TPU'''][value]			)


def    _snake_case  (	A			)		->       str:
							lowerCAmelCase__			  =      int(A			)
							return DynamoBackend(DYNAMO_BACKENDS[value]			).value


def    _snake_case  (	A			)		->       Tuple:
							lowerCAmelCase__			  =      int(A			)
							return PrecisionType(['''no''', '''fp16''', '''bf16''', '''fp8'''][value]			)


def    _snake_case  (	A			)		->       Union[str, Any]:
							lowerCAmelCase__			  =      int(A			)
							return SageMakerDistributedType(['''NO''', '''DATA_PARALLEL''', '''MODEL_PARALLEL'''][value]			)


def    _snake_case  (	A			)		->       List[str]:
							return {"yes": True, "no": False}[value.lower()]






class 						a__							(				argparse.RawDescriptionHelpFormatter    ):





							'''simple docstring'''






							def     __SCREAMING_SNAKE_CASE				(						self   ,       lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_  )			->				Dict:
														lowerCAmelCase__			  =      super()._format_usage(lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_   ,       lowerCamelCase_  )
														lowerCAmelCase__			  =      usage.replace('''<command> [<args>] '''   ,       ''''''  )
														return usage