"""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      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase=None     ,__UpperCAmelCase=None     ,__UpperCAmelCase=None			):






	"""simple docstring"""





	_lowercase :    Optional[Any]							=							True
	while ask_again:
		_lowercase :    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      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase=[]     ,__UpperCAmelCase=None     ,__UpperCAmelCase=0			):






	"""simple docstring"""





	_lowercase :    List[str]							=							BulletMenu(__UpperCAmelCase     ,__UpperCAmelCase			)
	_lowercase :    int							=							menu.run(default_choice=__UpperCAmelCase			)
	return convert_value(__UpperCAmelCase			) if convert_value is not None else result


def      __lowerCAmelCase(		__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    List[str]							=							int(__UpperCAmelCase			)
	return ComputeEnvironment(['LOCAL_MACHINE', 'AMAZON_SAGEMAKER'][value]			)


def      __lowerCAmelCase(		__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    Tuple							=							int(__UpperCAmelCase			)
	return DistributedType(['NO', 'MULTI_CPU', 'MULTI_XPU', 'MULTI_GPU', 'MULTI_NPU', 'TPU'][value]			)


def      __lowerCAmelCase(		__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    str							=							int(__UpperCAmelCase			)
	return DynamoBackend(DYNAMO_BACKENDS[value]			).value


def      __lowerCAmelCase(		__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    str							=							int(__UpperCAmelCase			)
	return PrecisionType(['no', 'fp16', 'bf16', 'fp8'][value]			)


def      __lowerCAmelCase(		__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    Optional[Any]							=							int(__UpperCAmelCase			)
	return SageMakerDistributedType(['NO', 'DATA_PARALLEL', 'MODEL_PARALLEL'][value]			)


def      __lowerCAmelCase(		__UpperCAmelCase			):






	"""simple docstring"""





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







class  _lowerCamelCase			(argparse.RawDescriptionHelpFormatter     ):







				def 							__UpperCAmelCase					( self    :       Dict			,					lowerCamelCase_    :       str			,					lowerCamelCase_    :       List[Any]			,					lowerCamelCase_    :       int			,					lowerCamelCase_    :       str						):

					"""simple docstring"""






					_lowercase :    Tuple							=							super()._format_usage(lowerCamelCase_			,					lowerCamelCase_			,					lowerCamelCase_			,					lowerCamelCase_						)
					_lowercase :    Union[str, Any]							=							usage.replace('<command> [<args>] '			,					''						)
					return usage




"""simple docstring"""







def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





	return not any(
	    neighbour == 1 and colored_vertices[i] == color
	    for i, neighbour in enumerate(__UpperCAmelCase			)			)


def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





	if index == len(__UpperCAmelCase			):
		return True

	# Recursive Step
	for i in range(__UpperCAmelCase			):
		if valid_coloring(graph[index]     ,__UpperCAmelCase     ,__UpperCAmelCase			):
			# Color current vertex
			_lowercase :    str							=							i
			# Validate coloring
			if util_color(__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase     ,index + 1			):
				return True
			# Backtrack
			_lowercase :    List[str]							=							-1
	return False







def      __lowerCAmelCase(		__UpperCAmelCase     ,__UpperCAmelCase			):






	"""simple docstring"""





	_lowercase :    Any							=							[-1] * len(__UpperCAmelCase			)

	if util_color(__UpperCAmelCase     ,__UpperCAmelCase     ,__UpperCAmelCase     ,0			):
		return colored_vertices

	return []



