

'''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      					=     [
    """EAGER""",
    """AOT_EAGER""",
    """INDUCTOR""",
    """NVFUSER""",
    """AOT_NVFUSER""",
    """AOT_CUDAGRAPHS""",
    """OFI""",
    """FX2TRT""",
    """ONNXRT""",
    """IPEX""",
]


def  a__       (    _SCREAMING_SNAKE_CASE   :       List[str]	,				_SCREAMING_SNAKE_CASE   :       Optional[int]=None	,				_SCREAMING_SNAKE_CASE   :       Dict=None	,				_SCREAMING_SNAKE_CASE   :       Any=None				)     ->					int:


	"""simple docstring"""





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


def  a__       (    _SCREAMING_SNAKE_CASE   :       List[str]	,				_SCREAMING_SNAKE_CASE   :       str=[]	,				_SCREAMING_SNAKE_CASE   :       int=None	,				_SCREAMING_SNAKE_CASE   :       Union[str, Any]=0				)     ->					List[Any]:


	"""simple docstring"""





	UpperCAmelCase_     :      Any						=  BulletMenu(_SCREAMING_SNAKE_CASE	,				_SCREAMING_SNAKE_CASE				)
	UpperCAmelCase_     :      Dict						=  menu.run(default_choice=_SCREAMING_SNAKE_CASE				)
	return convert_value(_SCREAMING_SNAKE_CASE				) if convert_value is not None else result


def  a__       (    _SCREAMING_SNAKE_CASE   :       Union[str, Any]				)     ->					Tuple:


	"""simple docstring"""





	UpperCAmelCase_     :      List[str]						=  int(_SCREAMING_SNAKE_CASE				)
	return ComputeEnvironment(["LOCAL_MACHINE", "AMAZON_SAGEMAKER"][value]				)


def  a__       (    _SCREAMING_SNAKE_CASE   :       Optional[Any]				)     ->					Dict:


	"""simple docstring"""





	UpperCAmelCase_     :      Dict						=  int(_SCREAMING_SNAKE_CASE				)
	return DistributedType(["NO", "MULTI_CPU", "MULTI_XPU", "MULTI_GPU", "MULTI_NPU", "TPU"][value]				)


def  a__       (    _SCREAMING_SNAKE_CASE   :       str				)     ->					Dict:


	"""simple docstring"""





	UpperCAmelCase_     :      Dict						=  int(_SCREAMING_SNAKE_CASE				)
	return DynamoBackend(DYNAMO_BACKENDS[value]				).value


def  a__       (    _SCREAMING_SNAKE_CASE   :       Any				)     ->					List[str]:


	"""simple docstring"""





	UpperCAmelCase_     :      Any						=  int(_SCREAMING_SNAKE_CASE				)
	return PrecisionType(["no", "fp16", "bf16", "fp8"][value]				)


def  a__       (    _SCREAMING_SNAKE_CASE   :       int				)     ->					Tuple:


	"""simple docstring"""





	UpperCAmelCase_     :      Union[str, Any]						=  int(_SCREAMING_SNAKE_CASE				)
	return SageMakerDistributedType(["NO", "DATA_PARALLEL", "MODEL_PARALLEL"][value]				)


def  a__       (    _SCREAMING_SNAKE_CASE   :       List[str]				)     ->					Union[str, Any]:


	"""simple docstring"""





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





class 					_snake_case		(argparse.RawDescriptionHelpFormatter):






			def 		UpperCamelCase__							(  self			,_snake_case			,_snake_case			,_snake_case			,_snake_case     ):
				UpperCAmelCase_     :      Optional[Any]						=  super()._format_usage(_snake_case			,_snake_case			,_snake_case			,_snake_case     )
				UpperCAmelCase_     :      int						=  usage.replace("<command> [<args>] "			,""     )
				return usage







from typing import TYPE_CHECKING

from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


a_      =     {'configuration_van': ['VAN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VanConfig']}


try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			a_      =     [
			    'VAN_PRETRAINED_MODEL_ARCHIVE_LIST',
			    'VanForImageClassification',
			    'VanModel',
			    'VanPreTrainedModel',
			]

if TYPE_CHECKING:
			from .configuration_van import VAN_PRETRAINED_CONFIG_ARCHIVE_MAP, VanConfig

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_van import (
						    VAN_PRETRAINED_MODEL_ARCHIVE_LIST,
						    VanForImageClassification,
						    VanModel,
						    VanPreTrainedModel,
						)

else:
			import sys

			a_      =     _LazyModule(__name__, globals()['__file__'], _import_structure)