





'''simple docstring'''






import re
import tempfile
import unittest
from pathlib import Path

from datasets.utils.metadata import DatasetMetadata
def 				_lowerCamelCase(	UpperCamelCase__     :			str		)		->	str:
    A							:							Dict				=    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__		)]		)


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

Some cool dataset card
"""

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

Some cool dataset card
"""


snake_case_     			=						"""\
# Begin of markdown

Some cool dataset card
"""





class 	_lowercase    (				unittest.TestCase					):


   def        snake_case					(			self       ):
       with tempfile.TemporaryDirectory() as tmp_dir:
           A							:							Optional[Any]				=    Path(_UpperCAmelCase       ) / '''README.md'''
           with open(_UpperCAmelCase     , '''w+'''       ) as readme_file:
               readme_file.write(_UpperCAmelCase       )
           A							:							Optional[int]				=    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       )
           A							:							Dict				=    DatasetMetadata.from_readme(_UpperCAmelCase       )
           self.assertDictEqual(_UpperCAmelCase     , {}       )

           with open(_UpperCAmelCase     , '''w+'''       ) as readme_file:
               readme_file.write(_UpperCAmelCase       )
           A							:							Optional[int]				=    DatasetMetadata.from_readme(_UpperCAmelCase       )
           self.assertEqual(_UpperCAmelCase     , {}       )


   def        snake_case					(			self       ):
       A							:							Tuple				=    _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       )

       A							:							Tuple				=    _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       )

       A							:							Optional[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:
            - 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'''






import timeit


class 	_lowercase    :


   def __init__(			self     , _UpperCAmelCase       ):
       if isinstance(_UpperCAmelCase     , _UpperCAmelCase       ):  # Initializes a matrix identical to the one provided.
           A							:							List[Any]				=    arg
           A							:							Dict				=    len(_UpperCAmelCase       )
       else:  # Initializes a square matrix of the given size and set values to zero.
           A							:							str				=    arg
           A							:							Union[str, Any]				=    [[0 for _ in range(self.n       )] for _ in range(self.n       )]


   def __mul__(			self     , _UpperCAmelCase       ):
       A							:							List[str]				=    Matrix(self.n       )
       for i in range(self.n       ):
           for j in range(self.n       ):
               for k in range(self.n       ):
                   matrix.t[i][j] += self.t[i][k] * b.t[k][j]
       return matrix







def 				_lowerCamelCase(	UpperCamelCase__     :			Union[str, Any]     ,							UpperCamelCase__     :			int		)		->	Union[str, Any]:
    A							:							Tuple				=    Matrix([[1, 0], [0, 1]]		)
    while b > 0:
        if b & 1:
            matrix *= a
        a *= a
        b >>= 1
    return matrix
def 				_lowerCamelCase(	UpperCamelCase__     :			int     ,							UpperCamelCase__     :			Tuple     ,							UpperCamelCase__     :			Any		)		->	Any:
    # Trivial Cases
    if n == 1:
        return fa
    elif n == 2:
        return fa
    A							:							Optional[Any]				=    Matrix([[1, 1], [1, 0]]		)
    A							:							int				=    modular_exponentiation(UpperCamelCase__     ,							n - 2		)
    return fa * matrix.t[0][0] + fa * matrix.t[0][1]
def 				_lowerCamelCase(	UpperCamelCase__     :			str     ,							UpperCamelCase__     :			Optional[Any]     ,							UpperCamelCase__     :			Any		)		->	List[Any]:
    # Trivial Cases
    if n == 1:
        return fa
    elif n == 2:
        return fa

    A							:							str				=    fa
    A							:							List[Any]				=    fa
    n -= 2

    while n > 0:
        A,						A							:							List[str]				=    fn_a + fn_a, fn_a
        n -= 1

    return fn_a
def 				_lowerCamelCase(	)		->	Union[str, Any]:
    A							:							Any				=    '''
from random import randint
from __main__ import fibonacci_with_matrix_exponentiation
'''
    A							:							Optional[int]				=    '''fibonacci_with_matrix_exponentiation(randint(1,70000), 1, 1)'''
    A							:							List[Any]				=    timeit.timeit(setup=UpperCamelCase__     ,							stmt=UpperCamelCase__     ,							number=100		)
    print('''With matrix exponentiation the average execution time is '''     ,							exec_time / 100		)
    return exec_time
def 				_lowerCamelCase(	)		->	List[Any]:
    A							:							str				=    '''
from random import randint
from __main__ import simple_fibonacci
'''
    A							:							Any				=    '''simple_fibonacci(randint(1,70000), 1, 1)'''
    A							:							str				=    timeit.timeit(setup=UpperCamelCase__     ,							stmt=UpperCamelCase__     ,							number=100		)
    print(
        '''Without matrix exponentiation the average execution time is '''     ,							exec_time / 100		)
    return exec_time
def 				_lowerCamelCase(	)		->	Optional[Any]:
    matrix_exponentiation_time()
    simple_fibonacci_time()


if __name__ == "__main__":
     main()
