

import re
import tempfile
import unittest
from pathlib import Path

from datasets.utils.metadata import DatasetMetadata







def     A_   (					_UpperCAmelCase					):

						'''simple docstring'''





						SCREAMING_SNAKE_CASE_:				Union[str, Any]							= min(re.search("^ +"       ,			_UpperCAmelCase					).end() if t.startswith(" "					) else 0 for t in string.splitlines()					)
						return "\n".join([line[indent_level:] for line in string.splitlines() if indent_level < len(_UpperCAmelCase					)]					)


lowerCAmelCase							:						List[str]     			=		"""\
---
language:
- zh
- en
task_ids:
- sentiment-classification
---
# Begin of markdown

Some cool dataset card
"""

lowerCAmelCase							:						Optional[int]     			=		"""\
---
---
# Begin of markdown

Some cool dataset card
"""


lowerCAmelCase							:						Tuple     			=		"""\
# Begin of markdown

Some cool dataset card
"""



class 						__lowercase       (				unittest.TestCase			):




			"""simple docstring"""







			def  _SCREAMING_SNAKE_CASE    (				self						:  Union[str, Any]):
									with tempfile.TemporaryDirectory() as tmp_dir:
															SCREAMING_SNAKE_CASE_:				Tuple							= Path(lowerCAmelCase__) / "README.md"
															with open(lowerCAmelCase__     ,		"w+") as readme_file:
																					readme_file.write(lowerCAmelCase__)
															SCREAMING_SNAKE_CASE_:				List[str]							= DatasetMetadata.from_readme(lowerCAmelCase__)
															self.assertDictEqual(lowerCAmelCase__     ,		{"language": ["zh", "en"], "task_ids": ["sentiment-classification"]})

															with open(lowerCAmelCase__     ,		"w+") as readme_file:
																					readme_file.write(lowerCAmelCase__)
															SCREAMING_SNAKE_CASE_:				Optional[Any]							= DatasetMetadata.from_readme(lowerCAmelCase__)
															self.assertDictEqual(lowerCAmelCase__     ,		{})

															with open(lowerCAmelCase__     ,		"w+") as readme_file:
																					readme_file.write(lowerCAmelCase__)
															SCREAMING_SNAKE_CASE_:				Dict							= DatasetMetadata.from_readme(lowerCAmelCase__)
															self.assertEqual(lowerCAmelCase__     ,		{})




			def  _SCREAMING_SNAKE_CASE    (				self						:  List[Any]):
									SCREAMING_SNAKE_CASE_:				Optional[Any]							= _dedent(
									    "\\n            annotations_creators:\n            - found\n            language_creators:\n            - found\n            language:\n            - en\n            license:\n            - unknown\n            multilinguality:\n            - monolingual\n            pretty_name: Test Dataset\n            size_categories:\n            - 10K<n<100K\n            source_datasets:\n            - extended|other-yahoo-webscope-l6\n            task_categories:\n            - question-answering\n            task_ids:\n            - open-domain-qa\n            ")
									assert DatasetMetadata.from_yaml_string(lowerCAmelCase__)

									SCREAMING_SNAKE_CASE_:				List[Any]							= _dedent(
									    "\\n            annotations_creators:\n            - found\n            language:\n            - en\n            license:\n            - unknown\n            multilinguality:\n            - monolingual\n            pretty_name: Test Dataset\n            size_categories:\n            - 10K<n<100K\n            source_datasets:\n            - extended|other-yahoo-webscope-l6\n            task_categories:\n            - question-answering\n            task_ids:\n            - open-domain-qa\n            task_ids:\n            - open-domain-qa\n            ")
									with self.assertRaises(lowerCAmelCase__):
															DatasetMetadata.from_yaml_string(lowerCAmelCase__)

									SCREAMING_SNAKE_CASE_:				Optional[Any]							= _dedent(
									    "\\n            annotations_creators:\n            - found\n            language_creators:\n            - found\n            language:\n            - en\n            license:\n            - unknown\n            multilinguality:\n            - monolingual\n            pretty_name: Test Dataset\n            size_categories:\n            - 10K<n<100K\n            source_datasets:\n            - extended|other-yahoo-webscope-l6\n            task_categories:\n            - text-classification\n            task_ids:\n            - multi-class-classification\n            paperswithcode_id:\n            - squad\n            configs:\n            - en\n            train-eval-index:\n            - config: en\n              task: text-classification\n              task_id: multi_class_classification\n              splits:\n                train_split: train\n                eval_split: test\n              col_mapping:\n                text: text\n                label: target\n              metrics:\n                - type: accuracy\n                  name: Accuracy\n            extra_gated_prompt: |\n              By clicking on “Access repository” below, you also agree to ImageNet Terms of Access:\n              [RESEARCHER_FULLNAME] (the \"Researcher\") has requested permission to use the ImageNet database (the \"Database\") at Princeton University and Stanford University. In exchange for such permission, Researcher hereby agrees to the following terms and conditions:\n              1. Researcher shall use the Database only for non-commercial research and educational purposes.\n            extra_gated_fields:\n              Company: text\n              Country: text\n              I agree to use this model for non-commerical use ONLY: checkbox\n            ")
									assert DatasetMetadata.from_yaml_string(lowerCAmelCase__)









import heapq







def     A_   (					_UpperCAmelCase       ,			_UpperCAmelCase       ,			_UpperCAmelCase					):
						SCREAMING_SNAKE_CASE_:				List[Any]							= [(0, start)]  # cost from start node,end node
						SCREAMING_SNAKE_CASE_:				Any							= set()
						while heap:
												((SCREAMING_SNAKE_CASE_)	,					(SCREAMING_SNAKE_CASE_)):				Tuple							= heapq.heappop(_UpperCAmelCase					)
												if u in visited:
																		continue
												visited.add(_UpperCAmelCase					)
												if u == end:
																		return cost
												for v, c in graph[u]:
																		if v in visited:
																								continue
																		SCREAMING_SNAKE_CASE_:				List[str]							= cost + c
																		heapq.heappush(_UpperCAmelCase       ,			(next_item, v)					)
						return -1


lowerCAmelCase							:						Optional[Any]     			=		{
    """A""": [["""B""", 2], ["""C""", 5]],
    """B""": [["""A""", 2], ["""D""", 3], ["""E""", 1], ["""F""", 1]],
    """C""": [["""A""", 5], ["""F""", 3]],
    """D""": [["""B""", 3]],
    """E""": [["""B""", 4], ["""F""", 3]],
    """F""": [["""C""", 3], ["""E""", 3]],
}
lowerCAmelCase							:						Tuple     			=		{
    """B""": [["""C""", 1]],
    """C""": [["""D""", 1]],
    """D""": [["""F""", 1]],
    """E""": [["""B""", 1], ["""F""", 3]],
    """F""": [],
}
lowerCAmelCase							:						str     			=		{
    """B""": [["""C""", 1]],
    """C""": [["""D""", 1]],
    """D""": [["""F""", 1]],
    """E""": [["""B""", 1], ["""G""", 2]],
    """F""": [],
    """G""": [["""F""", 1]],
}

lowerCAmelCase							:						Union[str, Any]     			=		dijkstra(G, """E""", """C""")
print(short_distance)  # E -- 3 --> F -- 3 --> C == 6

lowerCAmelCase							:						Tuple     			=		dijkstra(Ga, """E""", """F""")
print(short_distance)  # E -- 3 --> F == 3

lowerCAmelCase							:						Union[str, Any]     			=		dijkstra(Ga, """E""", """F""")
print(short_distance)  # E -- 2 --> G -- 1 --> F == 3

if __name__ == "__main__":
						import doctest

						doctest.testmod()






