"""simple docstring"""


from collections.abc import Callable


class        a				:


    def __init__(					self	:  Dict   ,				__lowerCAmelCase	:  Callable | None = None					):
      # Stores actual heap items.
      _UpperCAmelCase						 =      []
      # Stores indexes of each item for supporting updates and deletion.
      _UpperCAmelCase						 =      {}
      # Stores current size of heap.
      _UpperCAmelCase						 =      0
      # Stores function used to evaluate the score of an item on which basis ordering
      # will be done.
      _UpperCAmelCase						 =      key or (lambda __lowerCAmelCase					: x)


    def      lowerCAmelCase_  (					self	:  Dict   ,				__lowerCAmelCase	:  int					):
      return int((i - 1) / 2					) if i > 0 else None


    def      lowerCAmelCase_  (					self	:  Optional[int]   ,				__lowerCAmelCase	:  int					):
      _UpperCAmelCase						 =      int(2 * i + 1					)
      return left if 0 < left < self.size else None


    def      lowerCAmelCase_  (					self	:  Dict   ,				__lowerCAmelCase	:  int					):
      _UpperCAmelCase						 =      int(2 * i + 2					)
      return right if 0 < right < self.size else None


    def      lowerCAmelCase_  (					self	:  List[str]   ,				__lowerCAmelCase	:  int   ,				__lowerCAmelCase	:  int					):
      _UpperCAmelCase ,				_UpperCAmelCase						 =      (
          self.pos_map[self.arr[j][0]],
          self.pos_map[self.arr[i][0]],
      )
      # Then swap the items in the list.
      _UpperCAmelCase ,				_UpperCAmelCase						 =      self.arr[j], self.arr[i]


    def      lowerCAmelCase_  (					self	:  Tuple   ,				__lowerCAmelCase	:  int   ,				__lowerCAmelCase	:  int					):
      return self.arr[i][1] < self.arr[j][1]


    def      lowerCAmelCase_  (					self	:  Optional[Any]   ,				__lowerCAmelCase	:  int					):
      _UpperCAmelCase						 =      self._left(__lowerCAmelCase					)
      _UpperCAmelCase						 =      self._right(__lowerCAmelCase					)
      _UpperCAmelCase						 =      i

      if left is not None and not self._cmp(__lowerCAmelCase   ,				__lowerCAmelCase					):
        _UpperCAmelCase						 =      left
      if right is not None and not self._cmp(__lowerCAmelCase   ,				__lowerCAmelCase					):
        _UpperCAmelCase						 =      right

      return valid_parent


    def      lowerCAmelCase_  (					self	:  str   ,				__lowerCAmelCase	:  int					):
      _UpperCAmelCase						 =      self._parent(__lowerCAmelCase					)
      while parent is not None and not self._cmp(__lowerCAmelCase   ,				__lowerCAmelCase					):
        self._swap(__lowerCAmelCase   ,				__lowerCAmelCase					)
        _UpperCAmelCase ,				_UpperCAmelCase						 =      parent, self._parent(__lowerCAmelCase					)


    def      lowerCAmelCase_  (					self	:  Any   ,				__lowerCAmelCase	:  int					):
      _UpperCAmelCase						 =      self._get_valid_parent(__lowerCAmelCase					)
      while valid_parent != index:
        self._swap(__lowerCAmelCase   ,				__lowerCAmelCase					)
        _UpperCAmelCase ,				_UpperCAmelCase						 =      valid_parent, self._get_valid_parent(__lowerCAmelCase					)


    def      lowerCAmelCase_  (					self	:  Union[str, Any]   ,				__lowerCAmelCase	:  int   ,				__lowerCAmelCase	:  int					):
      if item not in self.pos_map:
        return
      _UpperCAmelCase						 =      self.pos_map[item]
      _UpperCAmelCase						 =      [item, self.key(__lowerCAmelCase					)]
      # Make sure heap is right in both up and down direction.
      # Ideally only one of them will make any change.
      self._heapify_up(__lowerCAmelCase					)
      self._heapify_down(__lowerCAmelCase					)


    def      lowerCAmelCase_  (					self	:  int   ,				__lowerCAmelCase	:  int					):
      if item not in self.pos_map:
        return
      _UpperCAmelCase						 =      self.pos_map[item]
      del self.pos_map[item]
      _UpperCAmelCase						 =      self.arr[self.size - 1]
      _UpperCAmelCase						 =      index
      self.size -= 1
      # Make sure heap is right in both up and down direction. Ideally only one
      # of them will make any change- so no performance loss in calling both.
      if self.size > index:
        self._heapify_up(__lowerCAmelCase					)
        self._heapify_down(__lowerCAmelCase					)


    def      lowerCAmelCase_  (					self	:  Tuple   ,				__lowerCAmelCase	:  int   ,				__lowerCAmelCase	:  int					):
      _UpperCAmelCase						 =      len(self.arr					)
      if arr_len == self.size:
        self.arr.append([item, self.key(__lowerCAmelCase					)]					)
      else:
        _UpperCAmelCase						 =      [item, self.key(__lowerCAmelCase					)]
      _UpperCAmelCase						 =      self.size
      self.size += 1
      self._heapify_up(self.size - 1					)


    def      lowerCAmelCase_  (					self	:  Optional[Any]					):
      return self.arr[0] if self.size else None


    def      lowerCAmelCase_  (					self	:  str					):
      _UpperCAmelCase						 =      self.get_top()
      if top_item_tuple:
        self.delete_item(top_item_tuple[0]					)
      return top_item_tuple






def     __UpperCAmelCase					(			):







  """simple docstring"""


if __name__ == "__main__":
    import doctest

    doctest.testmod()

"""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					)}
