


'''simple docstring'''






import logging
import os

from .state import PartialState




class  a     (     logging.LoggerAdapter       ):
 @staticmethod
 def 							__UpperCAmelCase		( __magic_name__						)					->							Optional[int]:
      _a			      =							PartialState()
      return not main_process_only or (main_process_only and state.is_main_process)




 def 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__      ,				*__magic_name__      ,				**__magic_name__						)					->							Optional[Any]:
      if PartialState._shared_state == {}:
           raise RuntimeError(
               'You must initialize the accelerate state by calling either `PartialState()` or `Accelerator()` before using the logging utility.'						)
      _a			      =							kwargs.pop('main_process_only'      ,				__magic_name__						)
      _a			      =							kwargs.pop('in_order'      ,				__magic_name__						)

      if self.isEnabledFor(__magic_name__						):
           if self._should_log(__magic_name__						):
                _a      ,   _a			      =							self.process(__magic_name__      ,				__magic_name__						)
                self.logger.log(__magic_name__      ,				__magic_name__      ,				*__magic_name__      ,				**__magic_name__						)

           elif in_order:
                _a			      =							PartialState()
                for i in range(state.num_processes						):
                     if i == state.process_index:
                          _a      ,   _a			      =							self.process(__magic_name__      ,				__magic_name__						)
                          self.logger.log(__magic_name__      ,				__magic_name__      ,				*__magic_name__      ,				**__magic_name__						)
                     state.wait_for_everyone()






def 	_A				(lowerCAmelCase__  :str				,						lowerCAmelCase__  :str = None		)   ->  Dict:




     '''simple docstring'''



     if log_level is None:
          _a			      =							os.environ.get('ACCELERATE_LOG_LEVEL'				,						lowerCAmelCase__		)
     _a			      =							logging.getLogger(lowerCAmelCase__		)
     if log_level is not None:
          logger.setLevel(log_level.upper()		)
          logger.root.setLevel(log_level.upper()		)
     return MultiProcessAdapter(lowerCAmelCase__				,						{}		)





'''simple docstring'''






import datasets


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

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

a_					:    Optional[Any]          =    "\nComputes XNLI score which is just simple accuracy.\nArgs:\n    predictions: Predicted labels.\n    references: Ground truth labels.\nReturns:\n    'accuracy': accuracy\nExamples:\n\n    >>> predictions = [0, 1]\n    >>> references = [0, 1]\n    >>> xnli_metric = datasets.load_metric(\"xnli\")\n    >>> results = xnli_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {'accuracy': 1.0}\n"






def 	_A				(lowerCAmelCase__  :List[Any]				,						lowerCAmelCase__  :Tuple		)   ->  Dict:




     '''simple docstring'''



     return (preds == labels).mean()






@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION  ,				_KWARGS_DESCRIPTION       )
class  a     (     datasets.Metric       ):
 def 							__UpperCAmelCase		( self						)					->							Dict:
      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 							__UpperCAmelCase		( self      ,				__magic_name__      ,				__magic_name__						)					->							Dict:
      return {"accuracy": simple_accuracy(__magic_name__      ,				__magic_name__						)}

