


from queue import PriorityQueue
from typing import Any

import numpy as np
def 				UpperCamelCase__					(  SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	):
 for nxt, d in graph[v]:
  if nxt in visited_forward:
   continue
  __lowerCamelCase		:							Dict		 =						cst_fwd.get(SCREAMING_SNAKE_CASE__      ,	np.inf						)
  __lowerCamelCase		:							Union[str, Any]		 =						cst_fwd[v] + d
  if new_cost_f < old_cost_f:
   queue.put((new_cost_f, nxt)						)
   __lowerCamelCase		:							Optional[Any]		 =						new_cost_f
   __lowerCamelCase		:							Dict		 =						v
  if nxt in visited_backward:
   if cst_fwd[v] + d + cst_bwd[nxt] < shortest_distance:
    __lowerCamelCase		:							Optional[Any]		 =						cst_fwd[v] + d + cst_bwd[nxt]
 return shortest_distance
def 				UpperCamelCase__					(  SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__						):
 __lowerCamelCase		:							Tuple		 =						-1

 __lowerCamelCase		:							Optional[int]		 =						set()
 __lowerCamelCase		:							Optional[int]		 =						set()
 __lowerCamelCase		:							Optional[Any]		 =						{source: 0}
 __lowerCamelCase		:							Optional[Any]		 =						{destination: 0}
 __lowerCamelCase		:							Tuple		 =						{source: None}
 __lowerCamelCase		:							List[str]		 =						{destination: None}
 __lowerCamelCase		:							PriorityQueue[Any]		 =						PriorityQueue()
 __lowerCamelCase		:							PriorityQueue[Any]		 =						PriorityQueue()

 __lowerCamelCase		:							Any		 =						np.inf

 queue_forward.put((0, source)						)
 queue_backward.put((0, destination)						)

 if source == destination:
  return 0

 while not queue_forward.empty() and not queue_backward.empty():
  __lowerCamelCase ,					__lowerCamelCase		:							List[Any]		 =						queue_forward.get()
  visited_forward.add(SCREAMING_SNAKE_CASE__						)

  __lowerCamelCase ,					__lowerCamelCase		:							Tuple		 =						queue_backward.get()
  visited_backward.add(SCREAMING_SNAKE_CASE__						)

  __lowerCamelCase		:							List[str]		 =						pass_and_relaxation(
      SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	)

  __lowerCamelCase		:							str		 =						pass_and_relaxation(
      SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	)

  if cst_fwd[v_fwd] + cst_bwd[v_bwd] >= shortest_distance:
   break

 if shortest_distance != np.inf:
  __lowerCamelCase		:							Optional[int]		 =						shortest_distance
 return shortest_path_distance


lowercase_	   =     {
    'B': [['C', 1]],
    'C': [['D', 1]],
    'D': [['F', 1]],
    'E': [['B', 1], ['G', 2]],
    'F': [],
    'G': [['F', 1]],
}
lowercase_	   =     {
    'B': [['E', 1]],
    'C': [['B', 1]],
    'D': [['C', 1]],
    'F': [['D', 1], ['G', 1]],
    'E': [[None, np.inf]],
    'G': [['E', 2]],
}

if __name__ == "__main__":
       import doctest

       doctest.testmod()





import datasets


lowercase_	   =     '\\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'

lowercase_	   =     '\\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'

lowercase_	   =     '\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 				UpperCamelCase__					(  SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__						):
 return (preds == labels).mean()



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




      '''simple docstring'''


      def 					_snake_case     (    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 					_snake_case     (    self:	int						,				a:	Optional[Any]						,				a:	Optional[Any]    ):
       return {"accuracy": simple_accuracy(a						,				a    )}

