




from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCamelCase__						=		logging.get_logger(__name__)

UpperCamelCase__						=		{
    'google/pegasus-x-base': 'https://huggingface.co/google/pegasus-x-base/resolve/main/config.json',
    'google/pegasus-x-large': 'https://huggingface.co/google/pegasus-x-large/resolve/main/config.json',
    # See all PEGASUS-X models at https://huggingface.co/models?filter=pegasus-x
}


class 							__SCREAMING_SNAKE_CASE				(						_UpperCAmelCase    ):
					_lowerCamelCase						    =					"""pegasus_x"""
					_lowerCamelCase						    =					["""past_key_values"""]
					_lowerCamelCase						    =					{"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}

					def __init__(							self					,			__lowercase=96_103					,			__lowercase=16_384					,			__lowercase=16					,			__lowercase=4_096					,			__lowercase=16					,			__lowercase=16					,			__lowercase=4_096					,			__lowercase=16					,			__lowercase=0.0					,			__lowercase=0.0					,			__lowercase=True					,			__lowercase=True					,			__lowercase="gelu"					,			__lowercase=1_024					,			__lowercase=0.1					,			__lowercase=0.0					,			__lowercase=0.0					,			__lowercase=0.02					,			__lowercase=0					,			__lowercase=True					,			__lowercase=0					,			__lowercase=1					,			__lowercase=1					,			__lowercase=32					,			__lowercase=512					,			__lowercase=True					,			**__lowercase					,			):







						'''simple docstring'''




						lowerCamelCase_				:						int				  =				vocab_size
						lowerCamelCase_				:						Union[str, Any]				  =				max_position_embeddings
						lowerCamelCase_				:						Optional[int]				  =				d_model
						lowerCamelCase_				:						List[Any]				  =				encoder_ffn_dim
						lowerCamelCase_				:						Tuple				  =				encoder_layers
						lowerCamelCase_				:						Dict				  =				encoder_attention_heads
						lowerCamelCase_				:						str				  =				decoder_ffn_dim
						lowerCamelCase_				:						Tuple				  =				decoder_layers
						lowerCamelCase_				:						str				  =				decoder_attention_heads
						lowerCamelCase_				:						int				  =				dropout
						lowerCamelCase_				:						Optional[Any]				  =				attention_dropout
						lowerCamelCase_				:						int				  =				activation_dropout
						lowerCamelCase_				:						int				  =				activation_function
						lowerCamelCase_				:						Optional[int]				  =				init_std
						lowerCamelCase_				:						Any				  =				encoder_layerdrop
						lowerCamelCase_				:						Union[str, Any]				  =				decoder_layerdrop
						lowerCamelCase_				:						Tuple				  =				use_cache
						lowerCamelCase_				:						Optional[int]				  =				encoder_layers
						lowerCamelCase_				:						str				  =				scale_embedding  # scale factor will be sqrt(d_model) if True

						lowerCamelCase_				:						Dict				  =				num_global_tokens
						lowerCamelCase_				:						Union[str, Any]				  =				block_size
						lowerCamelCase_				:						Union[str, Any]				  =				stagger_local_blocks

						super().__init__(
						    pad_token_id=lowercase_					,			eos_token_id=lowercase_					,			is_encoder_decoder=lowercase_					,			decoder_start_token_id=lowercase_					,			forced_eos_token_id=lowercase_					,			**lowercase_					,			)

					@property
					def       lowercase_				(							self   ):







						'''simple docstring'''




						return self.encoder_attention_heads





					@property
					def       lowercase_				(							self   ):







						'''simple docstring'''




						return self.d_model



import re
import tempfile
import unittest
from pathlib import Path

from datasets.utils.metadata import DatasetMetadata
def 		_snake_case(       SCREAMING_SNAKE_CASE__     :      str )				-> str:





    '''simple docstring'''






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


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

lowercase_									=    "\\n---\n---\n# Begin of markdown\n\nSome cool dataset card\n"


lowercase_									=    "\\n# Begin of markdown\n\nSome cool dataset card\n"


class 					A		(				unittest.TestCase					):







    """simple docstring"""





    def 		snake_case__	( self					:			List[Any]						)->       str:





        '''simple docstring'''







        with tempfile.TemporaryDirectory() as tmp_dir:
            A__        =  Path(lowercase_						) / 'README.md'
            with open(lowercase_,'w+'						) as readme_file:
                readme_file.write(lowercase_						)
            A__        =  DatasetMetadata.from_readme(lowercase_						)
            self.assertDictEqual(lowercase_,{'language': ['zh', 'en'], 'task_ids': ['sentiment-classification']}						)

            with open(lowercase_,'w+'						) as readme_file:
                readme_file.write(lowercase_						)
            A__        =  DatasetMetadata.from_readme(lowercase_						)
            self.assertDictEqual(lowercase_,{}						)

            with open(lowercase_,'w+'						) as readme_file:
                readme_file.write(lowercase_						)
            A__        =  DatasetMetadata.from_readme(lowercase_						)
            self.assertEqual(lowercase_,{}						)


    def 		snake_case__	( self					:			Tuple						)->       List[Any]:





        '''simple docstring'''







        A__        =  _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(lowercase_						)

        A__        =  _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(lowercase_						):
            DatasetMetadata.from_yaml_string(lowercase_						)

        A__        =  _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(lowercase_						)

