"""simple docstring"""


import platform
from argparse import ArgumentParser

import huggingface_hub

from .. import __version__ as version
from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available
from . import BaseDiffusersCLICommand






def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  return EnvironmentCommand()


class        a				(		lowerCAmelCase_   ):


    @staticmethod
    def      lowerCAmelCase_  (					__lowerCAmelCase	:  ArgumentParser					):
      _UpperCAmelCase						 =      parser.add_parser("""env"""					)
      download_parser.set_defaults(func=__lowerCAmelCase					)


    def      lowerCAmelCase_  (					self	:  Dict					):
      _UpperCAmelCase						 =      huggingface_hub.__version__

      _UpperCAmelCase						 =      """not installed"""
      _UpperCAmelCase						 =      """NA"""
      if is_torch_available():
        import torch

        _UpperCAmelCase						 =      torch.__version__
        _UpperCAmelCase						 =      torch.cuda.is_available()

      _UpperCAmelCase						 =      """not installed"""
      if is_transformers_available():
        import transformers

        _UpperCAmelCase						 =      transformers.__version__

      _UpperCAmelCase						 =      """not installed"""
      if is_accelerate_available():
        import accelerate

        _UpperCAmelCase						 =      accelerate.__version__

      _UpperCAmelCase						 =      """not installed"""
      if is_xformers_available():
        import xformers

        _UpperCAmelCase						 =      xformers.__version__

      _UpperCAmelCase						 =      {
          """`diffusers` version""": version,
          """Platform""": platform.platform(),
          """Python version""": platform.python_version(),
          """PyTorch version (GPU?)""": f'''{pt_version} ({pt_cuda_available})''',
          """Huggingface_hub version""": hub_version,
          """Transformers version""": transformers_version,
          """Accelerate version""": accelerate_version,
          """xFormers version""": xformers_version,
          """Using GPU in script?""": """<fill in>""",
          """Using distributed or parallel set-up in script?""": """<fill in>""",
      }

      print("""\nCopy-and-paste the text below in your GitHub issue and FILL OUT the two last points.\n"""					)
      print(self.format_dict(__lowerCAmelCase					)					)

      return info


    @staticmethod
    def      lowerCAmelCase_  (					__lowerCAmelCase	:  Tuple					):
      return "\n".join([f'''- {prop}: {val}''' for prop, val in d.items()]					) + "\n"

"""simple docstring"""


import datasets


UpperCAmelCase__  		=						"""\
@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\",
}
"""

UpperCAmelCase__  		=						"""\
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).
"""

UpperCAmelCase__  		=						"""
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        a				(		datasets.Metric   ):


    def      lowerCAmelCase_  (					self	:  Union[str, Any]					):
      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      lowerCAmelCase_  (					self	:  List[str]   ,				__lowerCAmelCase	:  int   ,				__lowerCAmelCase	:  Any					):
      return {"accuracy": simple_accuracy(__lowerCAmelCase   ,				__lowerCAmelCase					)}
