




# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
    is_vision_available,
)


UpperCamelCase__						=		{
    'configuration_tvlt': ['TVLT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TvltConfig'],
    'feature_extraction_tvlt': ['TvltFeatureExtractor'],
    'processing_tvlt': ['TvltProcessor'],
}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCamelCase__						=		[
							    'TVLT_PRETRAINED_MODEL_ARCHIVE_LIST',
							    'TvltModel',
							    'TvltForPreTraining',
							    'TvltForAudioVisualClassification',
							    'TvltPreTrainedModel',
							]

try:
							if not is_vision_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCamelCase__						=		['TvltImageProcessor']


if TYPE_CHECKING:
							from .configuration_tvlt import TVLT_PRETRAINED_CONFIG_ARCHIVE_MAP, TvltConfig
							from .processing_tvlt import TvltProcessor
							from .feature_extraction_tvlt import TvltFeatureExtractor

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_tvlt import (
														    TVLT_PRETRAINED_MODEL_ARCHIVE_LIST,
														    TvltForAudioVisualClassification,
														    TvltForPreTraining,
														    TvltModel,
														    TvltPreTrainedModel,
														)

							try:
														if not is_vision_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .image_processing_tvlt import TvltImageProcessor


else:
							import sys

							UpperCamelCase__						=		_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)






import re
import tempfile
import unittest
from pathlib import Path

from datasets.utils.metadata import DatasetMetadata





def      UpperCAmelCase  (						UpperCamelCase__   )     ->     str:







				'''simple docstring'''


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


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

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


__A						:		Any          =						"\\n# Begin of markdown\n\nSome cool dataset card\n"

class 		lowercase_       (	unittest.TestCase				):




					def     _lowercase						(   self:		List[str]):


									'''simple docstring'''


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

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







					def     _lowercase						(   self:		Optional[Any]):


									'''simple docstring'''


									__lowerCAmelCase					=  _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(_lowercase)

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

									__lowerCAmelCase					=  _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(_lowercase)





