

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


__SCREAMING_SNAKE_CASE     =						[
    """EAGER""",
    """AOT_EAGER""",
    """INDUCTOR""",
    """NVFUSER""",
    """AOT_NVFUSER""",
    """AOT_CUDAGRAPHS""",
    """OFI""",
    """FX2TRT""",
    """ONNXRT""",
    """IPEX""",
]



def 			__a		(       lowerCAmelCase__ :    Dict     ,  lowerCAmelCase__ :    Optional[int]=None     ,  lowerCAmelCase__ :    Any=None     ,  lowerCAmelCase__ :    Union[str, Any]=None      ):
     a__   :      Union[str, Any]     =						True
     while ask_again:
          a__   :      List[Any]     =						input(lowerCAmelCase__      )
          try:
               if default is not None and len(lowerCAmelCase__      ) == 0:
                    return default
               return convert_value(lowerCAmelCase__      ) if convert_value is not None else result
          except Exception:
               if error_message is not None:
                    print(lowerCAmelCase__      )



def 			__a		(       lowerCAmelCase__ :    Tuple     ,  lowerCAmelCase__ :    Union[str, Any]=[]     ,  lowerCAmelCase__ :    Dict=None     ,  lowerCAmelCase__ :    List[Any]=0      ):
     a__   :      int     =						BulletMenu(lowerCAmelCase__     ,  lowerCAmelCase__      )
     a__   :      Optional[Any]     =						menu.run(default_choice=lowerCAmelCase__      )
     return convert_value(lowerCAmelCase__      ) if convert_value is not None else result



def 			__a		(       lowerCAmelCase__ :    Tuple      ):
     a__   :      str     =						int(lowerCAmelCase__      )
     return ComputeEnvironment(['''LOCAL_MACHINE''', '''AMAZON_SAGEMAKER'''][value]      )



def 			__a		(       lowerCAmelCase__ :    str      ):
     a__   :      Any     =						int(lowerCAmelCase__      )
     return DistributedType(['''NO''', '''MULTI_CPU''', '''MULTI_XPU''', '''MULTI_GPU''', '''MULTI_NPU''', '''TPU'''][value]      )



def 			__a		(       lowerCAmelCase__ :    List[str]      ):
     a__   :      List[Any]     =						int(lowerCAmelCase__      )
     return DynamoBackend(DYNAMO_BACKENDS[value]      ).value



def 			__a		(       lowerCAmelCase__ :    Optional[Any]      ):
     a__   :      int     =						int(lowerCAmelCase__      )
     return PrecisionType(['''no''', '''fp16''', '''bf16''', '''fp8'''][value]      )



def 			__a		(       lowerCAmelCase__ :    str      ):
     a__   :      Tuple     =						int(lowerCAmelCase__      )
     return SageMakerDistributedType(['''NO''', '''DATA_PARALLEL''', '''MODEL_PARALLEL'''][value]      )



def 			__a		(       lowerCAmelCase__ :    Optional[int]      ):
     return {"yes": True, "no": False}[value.lower()]






class 			lowerCAmelCase__     (					argparse.RawDescriptionHelpFormatter						):




     """simple docstring"""





     def 			__lowerCAmelCase	(		self						:	List[str]      ,						A__						:	Optional[int]      ,						A__						:	str      ,						A__						:	str      ,						A__						:	List[Any]	)       ->			Dict:
          '''simple docstring'''




          a__   :      Dict     =						super()._format_usage(lowerCAmelCase__      ,						lowerCAmelCase__      ,						lowerCAmelCase__      ,						lowerCAmelCase__	)
          a__   :      Dict     =						usage.replace('''<command> [<args>] '''      ,						''''''	)
          return usage

def 							UpperCAmelCase		(       lowercase				):







				"""simple docstring"""



				if not isinstance(lowercase				,     lowercase				):
								raise ValueError('''Input must be an integer'''				)
				if input_num <= 0:
								raise ValueError('''Input must be positive'''				)
				return sum(
				    divisor for divisor in range(1				,     input_num // 2 + 1				) if input_num % divisor == 0				)


if __name__ == "__main__":
		import doctest

		doctest.testmod()