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





def 							UpperCAmelCase		(       lowercase				,     lowercase=None				,     lowercase=None				,     lowercase=None				):







				"""simple docstring"""



				__lowercase					     =				True
				while ask_again:
								__lowercase					     =				input(lowercase				)
								try:
												if default is not None and len(lowercase				) == 0:
																return default
												return convert_value(lowercase				) if convert_value is not None else result
								except Exception:
												if error_message is not None:
																print(lowercase				)





def 							UpperCAmelCase		(       lowercase				,     lowercase=[]				,     lowercase=None				,     lowercase=0				):







				"""simple docstring"""



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





def 							UpperCAmelCase		(       lowercase				):







				"""simple docstring"""



				__lowercase					     =				int(lowercase				)
				return ComputeEnvironment(['''LOCAL_MACHINE''', '''AMAZON_SAGEMAKER'''][value]				)





def 							UpperCAmelCase		(       lowercase				):







				"""simple docstring"""



				__lowercase					     =				int(lowercase				)
				return DistributedType(['''NO''', '''MULTI_CPU''', '''MULTI_XPU''', '''MULTI_GPU''', '''MULTI_NPU''', '''TPU'''][value]				)





def 							UpperCAmelCase		(       lowercase				):







				"""simple docstring"""



				__lowercase					     =				int(lowercase				)
				return DynamoBackend(DYNAMO_BACKENDS[value]				).value





def 							UpperCAmelCase		(       lowercase				):







				"""simple docstring"""



				__lowercase					     =				int(lowercase				)
				return PrecisionType(['''no''', '''fp16''', '''bf16''', '''fp8'''][value]				)





def 							UpperCAmelCase		(       lowercase				):







				"""simple docstring"""



				__lowercase					     =				int(lowercase				)
				return SageMakerDistributedType(['''NO''', '''DATA_PARALLEL''', '''MODEL_PARALLEL'''][value]				)





def 							UpperCAmelCase		(       lowercase				):







				"""simple docstring"""



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




class   _UpperCamelCase (		argparse.RawDescriptionHelpFormatter					):


			"""simple docstring"""






			def 			_SCREAMING_SNAKE_CASE     (  self ,  lowerCAmelCase__ ,  lowerCAmelCase__ ,  lowerCAmelCase__ ,  lowerCAmelCase__		)	->   Dict:

							'''simple docstring'''


							__lowercase					     =				super()._format_usage(lowerCAmelCase__ ,  lowerCAmelCase__ ,  lowerCAmelCase__ ,  lowerCAmelCase__		)
							__lowercase					     =				usage.replace('''<command> [<args>] ''' ,  ''''''		)
							return usage
import datasets


__a    :	Optional[Any]         =    """\
@InProceedings{conneau2018xnli,
  author = \"Conneau, Alexis
                 and Rinott, Ruty
                 and Lample, Guillaume
                 and Williams, Adina
                 and Bowman, Samuel R.
                 and Schwenk, Holger
                 and Stoyanov, Veselin\",
  title = \"XNLI: Evaluating Cross-lingual Sentence Representations\",
  booktitle = \"Proceedings of the 2018 Conference on Empirical Methods
               in Natural Language Processing\",
  year = \"2018\",
  publisher = \"Association for Computational Linguistics\",
  location = \"Brussels, Belgium\",
}
"""

__a    :	Optional[Any]         =    """\
XNLI is a subset of a few thousand examples from MNLI which has been translated
into a 14 different languages (some low-ish resource). As with MNLI, the goal is
to predict textual entailment (does sentence A imply/contradict/neither sentence
B) and is a classification task (given two sentences, predict one of three
labels).
"""

__a    :	str         =    """
Computes XNLI score which is just simple accuracy.
Args:
    predictions: Predicted labels.
    references: Ground truth labels.
Returns:
    'accuracy': accuracy
Examples:

    >>> predictions = [0, 1]
    >>> references = [0, 1]
    >>> xnli_metric = datasets.load_metric(\"xnli\")
    >>> results = xnli_metric.compute(predictions=predictions, references=references)
    >>> print(results)
    {'accuracy': 1.0}
"""





def 							UpperCAmelCase		(       lowercase				,     lowercase				):







				"""simple docstring"""



				return (preds == labels).mean()




@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION		,_KWARGS_DESCRIPTION					)
class   _UpperCamelCase (		datasets.Metric					):


			"""simple docstring"""






			def 			_SCREAMING_SNAKE_CASE     (  self		)	->   str:

							'''simple docstring'''


							return datasets.MetricInfo(
							    description=_DESCRIPTION ,  citation=_CITATION ,  inputs_description=_KWARGS_DESCRIPTION ,  features=datasets.Features(
							        {
							            '''predictions''': datasets.Value('''int64''' if self.config_name != '''sts-b''' else '''float32'''		),
							            '''references''': datasets.Value('''int64''' if self.config_name != '''sts-b''' else '''float32'''		),
							        }		) ,  codebase_urls=[] ,  reference_urls=[] ,  format='''numpy''' ,  )





			def 			_SCREAMING_SNAKE_CASE     (  self ,  lowerCAmelCase__ ,  lowerCAmelCase__		)	->   Dict:

							'''simple docstring'''


							return {"accuracy": simple_accuracy(lowerCAmelCase__ ,  lowerCAmelCase__		)}