





"""simple docstring"""




import re
import tempfile
import unittest
from pathlib import Path

from datasets.utils.metadata import DatasetMetadata





def 			a_							(				_lowercase  ):
						_UpperCamelCase     :   Optional[Any]      =       min(re.search('''^ +'''			,		_lowercase  ).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(_lowercase  )]  )


UpperCamelCase_	 ="""\
---
language:
- zh
- en
task_ids:
- sentiment-classification
---
# Begin of markdown

Some cool dataset card
"""

UpperCamelCase_	 ="""\
---
---
# Begin of markdown

Some cool dataset card
"""


UpperCamelCase_	 ="""\
# Begin of markdown

Some cool dataset card
"""






class 					_a		( unittest.TestCase							):






				def 							snake_case      (					self						:       Union[str, Any]				)      -> Dict:




										'''simple docstring'''



										with tempfile.TemporaryDirectory() as tmp_dir:
																_UpperCamelCase     :   Any      =       Path(lowerCAmelCase__				) / '''README.md'''
																with open(lowerCAmelCase__,					'''w+'''				) as readme_file:
																						readme_file.write(lowerCAmelCase__				)
																_UpperCamelCase     :   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__				)
																_UpperCamelCase     :   Any      =       DatasetMetadata.from_readme(lowerCAmelCase__				)
																self.assertDictEqual(lowerCAmelCase__,					{}				)

																with open(lowerCAmelCase__,					'''w+'''				) as readme_file:
																						readme_file.write(lowerCAmelCase__				)
																_UpperCamelCase     :   List[str]      =       DatasetMetadata.from_readme(lowerCAmelCase__				)
																self.assertEqual(lowerCAmelCase__,					{}				)






				def 							snake_case      (					self						:       Any				)      -> Optional[int]:




										'''simple docstring'''



										_UpperCamelCase     :   int      =       _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(lowerCAmelCase__				)

										_UpperCamelCase     :   List[Any]      =       _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(lowerCAmelCase__				):
																DatasetMetadata.from_yaml_string(lowerCAmelCase__				)

										_UpperCamelCase     :   Dict      =       _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(lowerCAmelCase__				)










def   _lowercase       (    _UpperCAmelCase					)    ->	bool:
				if not isinstance(_UpperCAmelCase      ,   _UpperCAmelCase					):
								lowerCamelCase									=F"""Input value of [number={number}] must be an integer"""
								raise TypeError(_UpperCAmelCase					)
				if number < 0 or number % 2 == 1:
								return False
				lowerCamelCase									=int(number**0.5					)
				return number == number_sqrt * (number_sqrt + 1)


if __name__ == "__main__":
							import doctest

							doctest.testmod()





