"""simple docstring"""



import copy

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


__magic_name__    				=					logging.get_logger(__name__)

class SCREAMING_SNAKE_CASE     (    __SCREAMING_SNAKE_CASE	):







	"""simple docstring"""


	a_       :	Dict  			="hybrid-clip"
	a_       :	Tuple  			=True


	def __init__(   self		:      Any					,   _snake_case		:      Optional[Any]=512					,   **_snake_case		:      Dict				)				->			Dict:




				'''simple docstring'''






				super().__init__(**UpperCamelCase__				)

				if "text_config" not in kwargs:
							raise ValueError('`text_config` can not be `None`.'				)

				if "vision_config" not in kwargs:
							raise ValueError('`vision_config` can not be `None`.'				)

				a__     				=		kwargs.pop('text_config'				)
				a__     				=		kwargs.pop('vision_config'				)

				a__     				=		text_config.pop('model_type'				)
				a__     				=		vision_config.pop('model_type'				)

				from transformers import AutoConfig

				a__     				=		AutoConfig.for_model(UpperCamelCase__					,   **UpperCamelCase__				)

				if vision_model_type == "clip":
							a__     				=		AutoConfig.for_model(UpperCamelCase__					,   **UpperCamelCase__				).vision_config
				elif vision_model_type == "clip_vision_model":
							from transformers import CLIPVisionConfig

							a__     				=		CLIPVisionConfig(**UpperCamelCase__				)
				else:
							a__     				=		AutoConfig.for_model(UpperCamelCase__					,   **UpperCamelCase__				)

				a__     				=		projection_dim
				a__     				=		1.0


	@classmethod
	def        _lowerCAmelCase				(   cls		:      List[str]					,   _snake_case		:      PretrainedConfig					,   _snake_case		:      PretrainedConfig					,   **_snake_case		:      List[Any]				)				->			Union[str, Any]:




				'''simple docstring'''






				return cls(text_config=text_config.to_dict()					,   vision_config=vision_config.to_dict()					,   **UpperCamelCase__				)



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




				'''simple docstring'''






				a__     				=		copy.deepcopy(self.__dict__				)
				a__     				=		self.text_config.to_dict()
				a__     				=		self.vision_config.to_dict()
				a__     				=		self.__class__.model_type
				return output



"""simple docstring"""



import re
import tempfile
import unittest
from pathlib import Path

from datasets.utils.metadata import DatasetMetadata





def   _lowerCamelCase ( UpperCAmelCase__					)							->     str:


   '''simple docstring'''


   a__     				=		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__					)]					)


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

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


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




class SCREAMING_SNAKE_CASE     (    unittest.TestCase	):







 """simple docstring"""


 def        _lowerCAmelCase				(   self		:      Tuple				)				->			Dict:




    '''simple docstring'''






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

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

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



 def        _lowerCAmelCase				(   self		:      List[Any]				)				->			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(_snake_case				)

    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(_snake_case				):
       DatasetMetadata.from_yaml_string(_snake_case				)

    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(_snake_case				)


