






# 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


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


def        _a  (     UpperCamelCase_					:				str    ,   UpperCamelCase_					:				List[str]=None    ,   UpperCamelCase_					:				List[Any]=None    ,   UpperCamelCase_					:				Union[str, Any]=None   ) ->   int:
						"""simple docstring"""







						lowerCAmelCase__       =						True
						while ask_again:
												lowerCAmelCase__       =						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        _a  (     UpperCamelCase_					:				Any    ,   UpperCamelCase_					:				Tuple=[]    ,   UpperCamelCase_					:				Dict=None    ,   UpperCamelCase_					:				List[str]=0   ) ->   Union[str, Any]:
						"""simple docstring"""







						lowerCAmelCase__       =						BulletMenu(UpperCamelCase_    ,   UpperCamelCase_   )
						lowerCAmelCase__       =						menu.run(default_choice=UpperCamelCase_   )
						return convert_value(UpperCamelCase_   ) if convert_value is not None else result


def        _a  (     UpperCamelCase_					:				List[Any]   ) ->   int:
						"""simple docstring"""







						lowerCAmelCase__       =						int(UpperCamelCase_   )
						return ComputeEnvironment(["LOCAL_MACHINE", "AMAZON_SAGEMAKER"][value]   )


def        _a  (     UpperCamelCase_					:				Any   ) ->   str:
						"""simple docstring"""







						lowerCAmelCase__       =						int(UpperCamelCase_   )
						return DistributedType(["NO", "MULTI_CPU", "MULTI_XPU", "MULTI_GPU", "MULTI_NPU", "TPU"][value]   )


def        _a  (     UpperCamelCase_					:				Optional[Any]   ) ->   Dict:
						"""simple docstring"""







						lowerCAmelCase__       =						int(UpperCamelCase_   )
						return DynamoBackend(DYNAMO_BACKENDS[value]   ).value


def        _a  (     UpperCamelCase_					:				List[Any]   ) ->   List[str]:
						"""simple docstring"""







						lowerCAmelCase__       =						int(UpperCamelCase_   )
						return PrecisionType(["no", "fp16", "bf16", "fp8"][value]   )


def        _a  (     UpperCamelCase_					:				List[Any]   ) ->   str:
						"""simple docstring"""







						lowerCAmelCase__       =						int(UpperCamelCase_   )
						return SageMakerDistributedType(["NO", "DATA_PARALLEL", "MODEL_PARALLEL"][value]   )


def        _a  (     UpperCamelCase_					:				int   ) ->   Any:
						"""simple docstring"""







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





class      lowercase__     (			argparse.RawDescriptionHelpFormatter	):

	def 		UpperCAmelCase  (							self		,    __UpperCAmelCase		,    __UpperCAmelCase		,    __UpperCAmelCase		,    __UpperCAmelCase       )->					Tuple:







							'''simple docstring'''





							lowerCAmelCase__       =						super()._format_usage(__UpperCAmelCase		,    __UpperCAmelCase		,    __UpperCAmelCase		,    __UpperCAmelCase       )
							lowerCAmelCase__       =						usage.replace("<command> [<args>] "		,    ""       )
							return usage














# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.:
#   python ./utils/get_modified_files.py utils src tests examples
#
# it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered
# since the output of this script is fed into Makefile commands it doesn't print a newline after the results

import re
import subprocess
import sys


a_							=    subprocess.check_output('''git merge-base main HEAD'''.split()).decode('''utf-8''')
a_							=    subprocess.check_output(F"git diff --name-only {fork_point_sha}".split()).decode('''utf-8''').split()

a_							=    '''|'''.join(sys.argv[1:])
a_							=    re.compile(rF"^({joined_dirs}).*?\.py$")

a_							=    [x for x in modified_files if regex.match(x)]
print(''' '''.join(relevant_modified_files), end='''''')






