

"""simple docstring"""




import re
import tempfile
import unittest
from pathlib import Path

from datasets.utils.metadata import DatasetMetadata

def 		A    (       snake_case__      ):




			'''simple docstring'''


			SCREAMING_SNAKE_CASE__									= min(re.search("""^ +"""						,			snake_case__      ).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(snake_case__      )]      )


A_							:     Dict     =	"\\n---\nlanguage:\n- zh\n- en\ntask_ids:\n- sentiment-classification\n---\n# Begin of markdown\n\nSome cool dataset card\n"

A_							:     str     =	"\\n---\n---\n# Begin of markdown\n\nSome cool dataset card\n"


A_							:     int     =	"\\n# Begin of markdown\n\nSome cool dataset card\n"





class 				lowerCamelCase  (unittest.TestCase     ):

			def    SCREAMING_SNAKE_CASE			(   self			:  Optional[Any]    )				->      List[Any]:
						with tempfile.TemporaryDirectory() as tmp_dir:
									SCREAMING_SNAKE_CASE__									= Path(__UpperCAmelCase    ) / """README.md"""
									with open(__UpperCAmelCase      ,			"""w+"""    ) as readme_file:
												readme_file.write(__UpperCAmelCase    )
									SCREAMING_SNAKE_CASE__									= DatasetMetadata.from_readme(__UpperCAmelCase    )
									self.assertDictEqual(__UpperCAmelCase      ,			{"""language""": ["""zh""", """en"""], """task_ids""": ["""sentiment-classification"""]}    )

									with open(__UpperCAmelCase      ,			"""w+"""    ) as readme_file:
												readme_file.write(__UpperCAmelCase    )
									SCREAMING_SNAKE_CASE__									= DatasetMetadata.from_readme(__UpperCAmelCase    )
									self.assertDictEqual(__UpperCAmelCase      ,			{}    )

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





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

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

						SCREAMING_SNAKE_CASE__									= _dedent(
						    """\
            annotations_creators:
            - found
            language_creators:
            - found
            language:
            - en
            license:
            - unknown
            multilinguality:
            - monolingual
            pretty_name: Test Dataset
            size_categories:
            - 10K<n<100K
            source_datasets:
            - extended|other-yahoo-webscope-l6
            task_categories:
            - text-classification
            task_ids:
            - multi-class-classification
            paperswithcode_id:
            - squad
            configs:
            - en
            train-eval-index:
            - config: en
              task: text-classification
              task_id: multi_class_classification
              splits:
                train_split: train
                eval_split: test
              col_mapping:
                text: text
                label: target
              metrics:
                - type: accuracy
                  name: Accuracy
            extra_gated_prompt: |
              By clicking on “Access repository” below, you also agree to ImageNet Terms of Access:
              [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:
              1. Researcher shall use the Database only for non-commercial research and educational purposes.
            extra_gated_fields:
              Company: text
              Country: text
              I agree to use this model for non-commerical use ONLY: checkbox
            """    )
						assert DatasetMetadata.from_yaml_string(__UpperCAmelCase    )





"""simple docstring"""




from .hash_table import HashTable





class 				lowerCamelCase  (A__     ):

			def __init__(   self			:  List[str]      ,			*__UpperCAmelCase			:  Union[str, Any]      ,			**__UpperCAmelCase			:  Any    )				->      Optional[int]:
						super().__init__(*__UpperCAmelCase      ,			**__UpperCAmelCase    )





			def    SCREAMING_SNAKE_CASE			(   self			:  List[str]      ,			__UpperCAmelCase			:  int      ,			__UpperCAmelCase			:  Union[str, Any]=None    )				->      Optional[int]:
						SCREAMING_SNAKE_CASE__									= 1
						SCREAMING_SNAKE_CASE__									= self.hash_function(key + i * i    )

						while self.values[new_key] is not None and self.values[new_key] != key:
									i += 1
									SCREAMING_SNAKE_CASE__									= (
									    self.hash_function(key + i * i    )
									    if not self.balanced_factor() >= self.lim_charge
									    else None
									)

									if new_key is None:
												break

						return new_key


