
'''simple docstring'''







import inspect

import jax
import jax.lax as lax
import jax.numpy as jnp

from ..utils import add_start_docstrings
from ..utils.logging import get_logger


_lowercase :  Tuple    							=       get_logger(__name__)


_lowercase :  Union[str, Any]    							=       r"\n    Args:\n        input_ids (`jnp.ndarray` of shape `(batch_size, sequence_length)`):\n            Indices of input sequence tokens in the vocabulary.\n\n            Indices can be obtained using [`PreTrainedTokenizer`]. See [`PreTrainedTokenizer.encode`] and\n            [`PreTrainedTokenizer.__call__`] for details.\n\n            [What are input IDs?](../glossary#input-ids)\n        scores (`jnp.ndarray` of shape `(batch_size, config.vocab_size)`):\n            Prediction scores of a language modeling head. These can be logits for each vocabulary when not using beam\n            search or log softmax for each vocabulary token when using beam search\n        kwargs (`Dict[str, Any]`, *optional*):\n            Additional logits processor specific kwargs.\n\n    Return:\n        `jnp.ndarray` of shape `(batch_size, config.vocab_size)`: The processed prediction scores.\n\n"






class  lowerCAmelCase__   :






					@add_start_docstrings(__SCREAMING_SNAKE_CASE		)
					def __call__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											raise NotImplementedError(
											    F'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''		)







class  lowerCAmelCase__   :






					@add_start_docstrings(__SCREAMING_SNAKE_CASE		)
					def __call__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											raise NotImplementedError(
											    F'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''		)







class  lowerCAmelCase__   (  lowerCamelCase_     ):






					@add_start_docstrings(__SCREAMING_SNAKE_CASE		)
					def __call__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							**__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											for processor in self:
																	lowercase_	:     Dict													=       inspect.signature(processor.__call__		).parameters
																	if len(__SCREAMING_SNAKE_CASE		) > 3:
																							if not all(arg in kwargs for arg in list(function_args.keys()		)[2:]		):
																													raise ValueError(
																													    F'''Make sure that all the required parameters: {list(function_args.keys()		)} for '''
																													    F'''{processor.__class__} are passed to the logits processor.'''		)
																							lowercase_	:     Dict													=       processor(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							**__SCREAMING_SNAKE_CASE		)
																	else:
																							lowercase_	:     Dict													=       processor(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		)
											return scores







class  lowerCAmelCase__   (  lowerCamelCase_     ):






					def __init__(   self				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											if not isinstance(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		) or not (temperature > 0):
																	raise ValueError(F'''`temperature` has to be a strictly positive float, but is {temperature}'''		)

											lowercase_	:     int													=       temperature






					def __call__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_	:     Tuple													=       scores / self.temperature
											return scores







class  lowerCAmelCase__   (  lowerCamelCase_     ):






					def __init__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE = -float('''Inf'''		)				,							__SCREAMING_SNAKE_CASE = 1		):


											"""simple docstring"""





											if not isinstance(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		) or (top_p < 0 or top_p > 1.0):
																	raise ValueError(F'''`top_p` has to be a float > 0 and < 1, but is {top_p}'''		)
											if not isinstance(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		) or (min_tokens_to_keep < 1):
																	raise ValueError(F'''`min_tokens_to_keep` has to be a positive integer, but is {min_tokens_to_keep}'''		)

											lowercase_	:     Optional[int]													=       top_p
											lowercase_	:     Optional[Any]													=       filter_value
											lowercase_	:     Optional[Any]													=       min_tokens_to_keep






					def __call__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_						, lowercase_	:     Optional[int]													=       lax.top_k(__SCREAMING_SNAKE_CASE				,							scores.shape[-1]		)

											lowercase_	:     List[str]													=       jnp.full_like(__SCREAMING_SNAKE_CASE				,							self.filter_value		)
											lowercase_	:     List[Any]													=       jax.nn.softmax(__SCREAMING_SNAKE_CASE				,							axis=-1		).cumsum(axis=-1		)
											lowercase_	:     Dict													=       cumulative_probs < self.top_p

											# include the token that is higher than top_p as well
											lowercase_	:     List[Any]													=       jnp.roll(__SCREAMING_SNAKE_CASE				,							1		)
											score_mask |= score_mask.at[:, 0].set(__SCREAMING_SNAKE_CASE		)

											# min tokens to keep
											lowercase_	:     List[str]													=       score_mask.at[:, : self.min_tokens_to_keep].set(__SCREAMING_SNAKE_CASE		)

											lowercase_	:     Any													=       jnp.where(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		)
											lowercase_	:     str													=       jax.lax.sort_key_val(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		)[-1]

											return next_scores







class  lowerCAmelCase__   (  lowerCamelCase_     ):






					def __init__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE = -float('''Inf'''		)				,							__SCREAMING_SNAKE_CASE = 1		):


											"""simple docstring"""





											if not isinstance(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		) or top_k <= 0:
																	raise ValueError(F'''`top_k` has to be a strictly positive integer, but is {top_k}'''		)

											lowercase_	:     str													=       max(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		)
											lowercase_	:     Optional[Any]													=       filter_value






					def __call__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_						, lowercase_	:     Union[str, Any]													=       scores.shape
											lowercase_	:     int													=       jnp.full(batch_size * vocab_size				,							self.filter_value		)

											lowercase_	:     List[Any]													=       min(self.top_k				,							scores.shape[-1]		)  # Safety check
											lowercase_						, lowercase_	:     int													=       lax.top_k(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		)
											lowercase_	:     Dict													=       jnp.broadcast_to((jnp.arange(__SCREAMING_SNAKE_CASE		) * vocab_size)[:, None]				,							(batch_size, topk)		).flatten()
											lowercase_	:     int													=       topk_scores.flatten()
											lowercase_	:     Tuple													=       topk_indices.flatten() + shift

											lowercase_	:     str													=       next_scores_flat.at[topk_indices_flat].set(__SCREAMING_SNAKE_CASE		)
											lowercase_	:     Optional[Any]													=       next_scores_flat.reshape(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		)
											return next_scores







class  lowerCAmelCase__   (  lowerCamelCase_     ):






					def __init__(   self				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_	:     Dict													=       bos_token_id






					def __call__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_	:     Optional[Any]													=       jnp.full(scores.shape				,							-float('''inf'''		)		)

											lowercase_	:     Union[str, Any]													=       1 - jnp.bool_(cur_len - 1		)

											lowercase_	:     Optional[int]													=       jnp.where(__SCREAMING_SNAKE_CASE				,							new_scores.at[:, self.bos_token_id].set(0		)				,							__SCREAMING_SNAKE_CASE		)

											return scores







class  lowerCAmelCase__   (  lowerCamelCase_     ):






					def __init__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_	:     Any													=       max_length
											lowercase_	:     Union[str, Any]													=       eos_token_id






					def __call__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_	:     Optional[int]													=       jnp.full(scores.shape				,							-float('''inf'''		)		)

											lowercase_	:     List[str]													=       1 - jnp.bool_(cur_len - self.max_length + 1		)

											lowercase_	:     Union[str, Any]													=       jnp.where(__SCREAMING_SNAKE_CASE				,							new_scores.at[:, self.eos_token_id].set(0		)				,							__SCREAMING_SNAKE_CASE		)

											return scores







class  lowerCAmelCase__   (  lowerCamelCase_     ):






					def __init__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											if not isinstance(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		) or min_length < 0:
																	raise ValueError(F'''`min_length` has to be a positive integer, but is {min_length}'''		)

											if not isinstance(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		) or eos_token_id < 0:
																	raise ValueError(F'''`eos_token_id` has to be a positive integer, but is {eos_token_id}'''		)

											lowercase_	:     str													=       min_length
											lowercase_	:     List[Any]													=       eos_token_id






					def __call__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_	:     Dict													=       1 - jnp.clip(cur_len - self.min_length				,							0				,							1		)

											lowercase_	:     Dict													=       jnp.where(__SCREAMING_SNAKE_CASE				,							scores.at[:, self.eos_token_id].set(-float('''inf'''		)		)				,							__SCREAMING_SNAKE_CASE		)

											return scores







class  lowerCAmelCase__   (  lowerCamelCase_     ):






					def __init__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_	:     Optional[int]													=       list(__SCREAMING_SNAKE_CASE		)
											lowercase_	:     str													=       begin_index






					def __call__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_	:     List[str]													=       1 - jnp.bool_(cur_len - self.begin_index		)

											lowercase_	:     Optional[int]													=       jnp.where(__SCREAMING_SNAKE_CASE				,							scores.at[:, self.begin_suppress_tokens].set(-float('''inf'''		)		)				,							__SCREAMING_SNAKE_CASE		)

											return scores







class  lowerCAmelCase__   (  lowerCamelCase_     ):






					def __init__(   self				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_	:     Optional[int]													=       list(__SCREAMING_SNAKE_CASE		)






					def __call__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_	:     Tuple													=       scores.at[..., self.suppress_tokens].set(-float('''inf'''		)		)

											return scores







class  lowerCAmelCase__   (  lowerCamelCase_     ):






					def __init__(   self				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_	:     List[str]													=       dict(__SCREAMING_SNAKE_CASE		)
											# Converts the dictionary of format {index: token} containing the tokens to be forced to an array, where the
											# index of the array corresponds to the index of the token to be forced, for XLA compatibility.
											# Indexes without forced tokens will have a negative value.
											lowercase_	:     Optional[int]													=       jnp.ones((max(force_token_map.keys()		) + 1)				,							dtype=jnp.intaa		) * -1
											for index, token in force_token_map.items():
																	if token is not None:
																							lowercase_	:     List[Any]													=       force_token_array.at[index].set(__SCREAMING_SNAKE_CASE		)
											lowercase_	:     Optional[Any]													=       jnp.intaa(__SCREAMING_SNAKE_CASE		)






					def __call__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											def _force_token(__SCREAMING_SNAKE_CASE		):
																	lowercase_	:     Any													=       scores.shape[0]
																	lowercase_	:     str													=       self.force_token_array[generation_idx]

																	lowercase_	:     Union[str, Any]													=       jnp.ones_like(__SCREAMING_SNAKE_CASE				,							dtype=scores.dtype		) * -float('''inf'''		)
																	lowercase_	:     Optional[int]													=       jnp.zeros((batch_size, 1)				,							dtype=scores.dtype		)
																	lowercase_	:     int													=       lax.dynamic_update_slice(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							(0, current_token)		)
																	return new_scores

											lowercase_	:     Any													=       lax.cond(
											    cur_len >= self.force_token_array.shape[0]				,							lambda: scores				,							lambda: lax.cond(
											        self.force_token_array[cur_len] >= 0				,							lambda: _force_token(__SCREAMING_SNAKE_CASE		)				,							lambda: scores				,							)				,							)
											return scores







class  lowerCAmelCase__   (  lowerCamelCase_     ):






					def __init__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_	:     Optional[int]													=       generate_config.eos_token_id
											lowercase_	:     List[str]													=       generate_config.no_timestamps_token_id
											lowercase_	:     str													=       generate_config.no_timestamps_token_id + 1

											lowercase_	:     Any													=       decoder_input_length + 1

											if generate_config.is_multilingual:
																	# room for language token and task token
																	self.begin_index += 2
											if hasattr(__SCREAMING_SNAKE_CASE				,							'''max_initial_timestamp_index'''		):
																	lowercase_	:     List[Any]													=       generate_config.max_initial_timestamp_index
											else:
																	lowercase_	:     Dict													=       model_config.vocab_size
											if self.max_initial_timestamp_index is None:
																	lowercase_	:     Optional[Any]													=       model_config.vocab_size






					def __call__(   self				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											lowercase_	:     Any													=       scores.at[:, self.no_timestamps_token_id].set(-float('''inf'''		)		)

											def handle_pairs(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):
																	lowercase_	:     int													=       jnp.where((cur_len - self.begin_index) >= 1				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		)
																	lowercase_	:     Dict													=       jnp.where(
																	    input_ids_k[cur_len - 1] >= self.timestamp_begin				,							True and last_was_timestamp				,							__SCREAMING_SNAKE_CASE				,							)

																	lowercase_	:     Optional[int]													=       jnp.where((cur_len - self.begin_index) < 2				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		)
																	lowercase_	:     str													=       jnp.where(
																	    input_ids_k[cur_len - 2] >= self.timestamp_begin				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE				,							)

																	return jnp.where(
																	    __SCREAMING_SNAKE_CASE				,							jnp.where(
																	        penultimate_was_timestamp > 0				,							scores_k.at[self.timestamp_begin :].set(-float('''inf'''		)		)				,							scores_k.at[: self.eos_token_id].set(-float('''inf'''		)		)				,							)				,							__SCREAMING_SNAKE_CASE				,							)

											lowercase_	:     Dict													=       jax.vmap(__SCREAMING_SNAKE_CASE		)(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		)

											lowercase_	:     Union[str, Any]													=       jnp.where(cur_len == self.begin_index				,							__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		)
											lowercase_	:     Optional[Any]													=       jnp.where(
											    self.max_initial_timestamp_index is not None				,							True and apply_max_initial_timestamp				,							__SCREAMING_SNAKE_CASE				,							)

											lowercase_	:     Union[str, Any]													=       self.timestamp_begin + self.max_initial_timestamp_index

											lowercase_	:     Optional[Any]													=       jnp.where(
											    __SCREAMING_SNAKE_CASE				,							scores.at[:, last_allowed + 1 :].set(-float('''inf'''		)		)				,							__SCREAMING_SNAKE_CASE				,							)

											# if sum of probability over timestamps is above any other token, sample timestamp
											lowercase_	:     List[Any]													=       jax.nn.log_softmax(__SCREAMING_SNAKE_CASE				,							axis=-1		)

											def handle_cumulative_probs(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		):
																	lowercase_	:     Union[str, Any]													=       jax.nn.logsumexp(logprobs_k[self.timestamp_begin :]				,							axis=-1		)
																	lowercase_	:     List[str]													=       jnp.max(logprobs_k[: self.timestamp_begin]		)
																	return jnp.where(
																	    timestamp_logprob > max_text_token_logprob				,							scores_k.at[: self.timestamp_begin].set(-float('''inf'''		)		)				,							__SCREAMING_SNAKE_CASE				,							)

											lowercase_	:     int													=       jax.vmap(__SCREAMING_SNAKE_CASE		)(__SCREAMING_SNAKE_CASE				,							__SCREAMING_SNAKE_CASE		)

											return scores





'''simple docstring'''







import re
import tempfile
from pathlib import Path

import pytest
import yaml

from datasets.utils.readme import ReadMe


# @pytest.fixture
# def example_yaml_structure():

_lowercase :  Union[str, Any]    							=       yaml.safe_load(
    "\\nname: \"\"\nallow_empty: false\nallow_empty_text: true\nsubsections:\n  - name: \"Dataset Card for X\" # First-level markdown heading\n    allow_empty: false\n    allow_empty_text: true\n    subsections:\n      - name: \"Table of Contents\"\n        allow_empty: false\n        allow_empty_text: false\n        subsections: null\n      - name: \"Dataset Description\"\n        allow_empty: false\n        allow_empty_text: false\n        subsections:\n          - name: \"Dataset Summary\"\n            allow_empty: false\n            allow_empty_text: false\n            subsections: null\n          - name: \"Supported Tasks and Leaderboards\"\n            allow_empty: true\n            allow_empty_text: true\n            subsections: null\n          - name: Languages\n            allow_empty: false\n            allow_empty_text: true\n            subsections: null\n"
)


_lowercase :  int    							=       {
    "name": "root",
    "text": "",
    "is_empty_text": True,
    "subsections": [
        {
            "name": "Dataset Card for My Dataset",
            "text": "",
            "is_empty_text": True,
            "subsections": [
                {"name": "Table of Contents", "text": "Some text here.", "is_empty_text": False, "subsections": []},
                {
                    "name": "Dataset Description",
                    "text": "Some text here.",
                    "is_empty_text": False,
                    "subsections": [
                        {
                            "name": "Dataset Summary",
                            "text": "Some text here.",
                            "is_empty_text": False,
                            "subsections": [],
                        },
                        {
                            "name": "Supported Tasks and Leaderboards",
                            "text": "",
                            "is_empty_text": True,
                            "subsections": [],
                        },
                        {"name": "Languages", "text": "Language Text", "is_empty_text": False, "subsections": []},
                    ],
                },
            ],
        }
    ],
}


_lowercase :  Optional[Any]    							=       "\\n---\nlanguage:\n- zh\n- en\n---\n\n# Dataset Card for My Dataset\n## Table of Contents\nSome text here.\n## Dataset Description\nSome text here.\n### Dataset Summary\nSome text here.\n### Supported Tasks and Leaderboards\n### Languages\nLanguage Text\n"


_lowercase :  Union[str, Any]    							=       "\\n---\nlanguage:\n- zh\n- en\n---\n\n# Dataset Card for My Dataset\n## Table of Contents\nSome text here.\n## Dataset Description\nSome text here.\n### Dataset Summary\nSome text here.\n#### Extra Ignored Subsection\n### Supported Tasks and Leaderboards\n### Languages\nLanguage Text\n"

_lowercase :  Any    							=       {
    "name": "root",
    "text": "",
    "is_empty_text": True,
    "subsections": [
        {
            "name": "Dataset Card for My Dataset",
            "text": "",
            "is_empty_text": True,
            "subsections": [
                {"name": "Table of Contents", "text": "Some text here.", "is_empty_text": False, "subsections": []},
                {
                    "name": "Dataset Description",
                    "text": "Some text here.",
                    "is_empty_text": False,
                    "subsections": [
                        {
                            "name": "Dataset Summary",
                            "text": "Some text here.",
                            "is_empty_text": False,
                            "subsections": [
                                {
                                    "name": "Extra Ignored Subsection",
                                    "text": "",
                                    "is_empty_text": True,
                                    "subsections": [],
                                }
                            ],
                        },
                        {
                            "name": "Supported Tasks and Leaderboards",
                            "text": "",
                            "is_empty_text": True,
                            "subsections": [],
                        },
                        {"name": "Languages", "text": "Language Text", "is_empty_text": False, "subsections": []},
                    ],
                },
            ],
        }
    ],
}

_lowercase :  str    							=       "\\n---\n---\n# Dataset Card for My Dataset\n## Table of Contents\nSome text here.\n## Dataset Description\nSome text here.\n### Dataset Summary\nSome text here.\n### Supported Tasks and Leaderboards\n### Languages\nLanguage Text\n"

_lowercase :  List[str]    							=       (
    "The following issues were found for the README at `{path}`:\n-\tEmpty YAML markers are present in the README."
)

_lowercase :  Tuple    							=       "\\n# Dataset Card for My Dataset\n## Table of Contents\nSome text here.\n## Dataset Description\nSome text here.\n### Dataset Summary\nSome text here.\n### Supported Tasks and Leaderboards\n### Languages\nLanguage Text\n"

_lowercase :  Optional[Any]    							=       (
    "The following issues were found for the README at `{path}`:\n-\tNo YAML markers are present in the README."
)

_lowercase :  Tuple    							=       "\\n---\n# Dataset Card for My Dataset\n## Table of Contents\nSome text here.\n## Dataset Description\nSome text here.\n### Dataset Summary\nSome text here.\n### Supported Tasks and Leaderboards\n### Languages\nLanguage Text\n"

_lowercase :  Optional[int]    							=       "The following issues were found for the README at `{path}`:\n-\tOnly the start of YAML tags present in the README."

_lowercase :  List[Any]    							=       "\\n---\nlanguage:\n- zh\n- en\n---\n\n# Dataset Card for My Dataset\n## Table of Contents\nSome text here.\n## Dataset Description\nSome text here.\n### Dataset Summary\n### Supported Tasks and Leaderboards\n### Languages\nLanguage Text\n"
_lowercase :  Optional[Any]    							=       "The following issues were found for the README at `{path}`:\n-\tExpected some content in section `Dataset Summary` but it is empty.\n-\tExpected some text in section `Dataset Summary` but it is empty (text in subsections are ignored)."


_lowercase :  Optional[int]    							=       "\\n---\nlanguage:\n- zh\n- en\n---\n\n# Dataset Card for My Dataset\n"
_lowercase :  Union[str, Any]    							=       "The following issues were found for the README at `{path}`:\n-\tExpected some content in section `Dataset Card for My Dataset` but it is empty.\n-\tSection `Dataset Card for My Dataset` expected the following subsections: `Table of Contents`, `Dataset Description`. Found 'None'."

_lowercase :  Union[str, Any]    							=       "\\n---\nlanguage:\n- zh\n- en\n---\n\n# Dataset Card for My Dataset\n## Table of Contents\nSome text here.\n## Dataset Description\nSome text here.\n### Dataset Summary\nSome text here.\n### Languages\nLanguage Text\n"

_lowercase :  int    							=       "The following issues were found for the README at `{path}`:\n-\tSection `Dataset Description` is missing subsection: `Supported Tasks and Leaderboards`."


_lowercase :  List[Any]    							=       "\\n---\nlanguage:\n- zh\n- en\n---\n\n# Dataset Card for My Dataset\n## Table of Contents\nSome text here.\n## Dataset Description\nSome text here.\n### Dataset Summary\nSome text here.\n### Supported Tasks and Leaderboards\n### Languages\n"

_lowercase :  int    							=       "The following issues were found for the README at `{path}`:\n-\tExpected some content in section `Languages` but it is empty."

_lowercase :  List[str]    							=       "\\n---\nlanguage:\n- zh\n- en\n---\n\n## Table of Contents\nSome text here.\n## Dataset Description\nSome text here.\n### Dataset Summary\nSome text here.\n### Supported Tasks and Leaderboards\n### Languages\nLanguage Text\n"
_lowercase :  str    							=       "The following issues were found for the README at `{path}`:\n-\tThe README has no first-level headings. One heading is expected. Skipping further validation for this README."

_lowercase :  Dict    							=       "\\n---\nlanguage:\n- zh\n- en\n---\n\n# Dataset Card for My Dataset\n## Table of Contents\nSome text here.\n## Dataset Description\nSome text here.\n### Dataset Summary\nSome text here.\n### Supported Tasks and Leaderboards\n### Languages\nLanguage Text\n# Dataset Card My Dataset\n"

_lowercase :  List[str]    							=       "The following issues were found for the README at `{path}`:\n-\tThe README has several first-level headings: `Dataset Card for My Dataset`, `Dataset Card My Dataset`. Only one heading is expected. Skipping further validation for this README."

_lowercase :  str    							=       "\\n---\nlanguage:\n- zh\n- en\n---\n\n# Dataset Card My Dataset\n## Table of Contents\nSome text here.\n## Dataset Description\nSome text here.\n### Dataset Summary\nSome text here.\n### Supported Tasks and Leaderboards\n### Languages\nLanguage Text\n"

_lowercase :  Union[str, Any]    							=       "The following issues were found for the README at `{path}`:\n-\tNo first-level heading starting with `Dataset Card for` found in README. Skipping further validation for this README."

_lowercase :  List[Any]    							=       ""

_lowercase :  Optional[Any]    							=       "The following issues were found for the README at `{path}`:\n-\tThe README has no first-level headings. One heading is expected. Skipping further validation for this README.\n-\tNo YAML markers are present in the README."

_lowercase :  List[Any]    							=       "\\n---\nlanguage:\n- zh\n- en\n---\n\n# Dataset Card for My Dataset\n# Dataset Card for My Dataset\n## Table of Contents\nSome text here.\n## Dataset Description\nSome text here.\n### Dataset Summary\nSome text here.\n### Supported Tasks and Leaderboards\n### Languages\nLanguage Text\n"

_lowercase :  Optional[Any]    							=       "The following issues were found while parsing the README at `{path}`:\n-\tMultiple sections with the same heading `Dataset Card for My Dataset` have been found. Please keep only one of these sections."
@pytest.mark.parametrize(
    '''readme_md, expected_dict'''      ,      [
        (README_CORRECT, CORRECT_DICT),
        (README_CORRECT_FOUR_LEVEL, CORRECT_DICT_FOUR_LEVEL),
    ]      ,      )
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: int      ,      __SCREAMING_SNAKE_CASE					: Optional[Any]							):



						"""simple docstring"""





						assert ReadMe.from_string(__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE							).to_dict() == expected_dict
@pytest.mark.parametrize(
    '''readme_md, expected_error'''      ,      [
        (README_NO_YAML, EXPECTED_ERROR_README_NO_YAML),
        (README_EMPTY_YAML, EXPECTED_ERROR_README_EMPTY_YAML),
        (README_INCORRECT_YAML, EXPECTED_ERROR_README_INCORRECT_YAML),
        (README_EMPTY, EXPECTED_ERROR_README_EMPTY),
        (README_NONE_SUBSECTION, EXPECTED_ERROR_README_NONE_SUBSECTION),
        (README_MISSING_FIRST_LEVEL, EXPECTED_ERROR_README_MISSING_FIRST_LEVEL),
        (README_MISSING_SUBSECTION, EXPECTED_ERROR_README_MISSING_SUBSECTION),
        (README_MISSING_TEXT, EXPECTED_ERROR_README_MISSING_TEXT),
        (README_WRONG_FIRST_LEVEL, EXPECTED_ERROR_README_WRONG_FIRST_LEVEL),
        (README_MULTIPLE_WRONG_FIRST_LEVEL, EXPECTED_ERROR_README_MULTIPLE_WRONG_FIRST_LEVEL),
        (README_MISSING_CONTENT, EXPECTED_ERROR_README_MISSING_CONTENT),
    ]      ,      )
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: Optional[Any]      ,      __SCREAMING_SNAKE_CASE					: Dict							):



						"""simple docstring"""





						with pytest.raises(__SCREAMING_SNAKE_CASE      ,      match=re.escape(expected_error.format(path='''root'''							)							)							):
												lowercase_	:     Optional[int]													=       ReadMe.from_string(__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE							)
												readme.validate()
@pytest.mark.parametrize(
    '''readme_md, expected_error'''      ,      [
        (README_MULTIPLE_SAME_HEADING_1, EXPECTED_ERROR_README_MULTIPLE_SAME_HEADING_1),
    ]      ,      )
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: Union[str, Any]      ,      __SCREAMING_SNAKE_CASE					: Dict							):



						"""simple docstring"""





						with pytest.raises(__SCREAMING_SNAKE_CASE      ,      match=re.escape(expected_error.format(path='''root'''							)							)							):
												ReadMe.from_string(__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE							)
@pytest.mark.parametrize(
    '''readme_md,'''      ,      [
        (README_MULTIPLE_SAME_HEADING_1),
    ]      ,      )
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: Any							):



						"""simple docstring"""





						ReadMe.from_string(__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE      ,      suppress_parsing_errors=__SCREAMING_SNAKE_CASE							)
@pytest.mark.parametrize(
    '''readme_md, expected_dict'''      ,      [
        (README_CORRECT, CORRECT_DICT),
        (README_CORRECT_FOUR_LEVEL, CORRECT_DICT_FOUR_LEVEL),
    ]      ,      )
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: List[Any]      ,      __SCREAMING_SNAKE_CASE					: str							):



						"""simple docstring"""





						with tempfile.TemporaryDirectory() as tmp_dir:
												lowercase_	:     Optional[int]													=       Path(__SCREAMING_SNAKE_CASE							) / '''README.md'''
												with open(__SCREAMING_SNAKE_CASE      ,      '''w+'''							) as readme_file:
																		readme_file.write(__SCREAMING_SNAKE_CASE							)
												lowercase_	:     Any													=       ReadMe.from_readme(__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE							).to_dict()
												assert out["name"] == path
												assert out["text"] == ""
												assert out["is_empty_text"]
												assert out["subsections"] == expected_dict["subsections"]
@pytest.mark.parametrize(
    '''readme_md, expected_error'''      ,      [
        (README_NO_YAML, EXPECTED_ERROR_README_NO_YAML),
        (README_EMPTY_YAML, EXPECTED_ERROR_README_EMPTY_YAML),
        (README_INCORRECT_YAML, EXPECTED_ERROR_README_INCORRECT_YAML),
        (README_EMPTY, EXPECTED_ERROR_README_EMPTY),
        (README_NONE_SUBSECTION, EXPECTED_ERROR_README_NONE_SUBSECTION),
        (README_MISSING_FIRST_LEVEL, EXPECTED_ERROR_README_MISSING_FIRST_LEVEL),
        (README_MISSING_SUBSECTION, EXPECTED_ERROR_README_MISSING_SUBSECTION),
        (README_MISSING_TEXT, EXPECTED_ERROR_README_MISSING_TEXT),
        (README_WRONG_FIRST_LEVEL, EXPECTED_ERROR_README_WRONG_FIRST_LEVEL),
        (README_MULTIPLE_WRONG_FIRST_LEVEL, EXPECTED_ERROR_README_MULTIPLE_WRONG_FIRST_LEVEL),
        (README_MISSING_CONTENT, EXPECTED_ERROR_README_MISSING_CONTENT),
    ]      ,      )
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: List[str]      ,      __SCREAMING_SNAKE_CASE					: Union[str, Any]							):



						"""simple docstring"""





						with tempfile.TemporaryDirectory() as tmp_dir:
												lowercase_	:     str													=       Path(__SCREAMING_SNAKE_CASE							) / '''README.md'''
												with open(__SCREAMING_SNAKE_CASE      ,      '''w+'''							) as readme_file:
																		readme_file.write(__SCREAMING_SNAKE_CASE							)
												lowercase_	:     List[str]													=       expected_error.format(path=__SCREAMING_SNAKE_CASE							)
												with pytest.raises(__SCREAMING_SNAKE_CASE      ,      match=re.escape(__SCREAMING_SNAKE_CASE							)							):
																		lowercase_	:     int													=       ReadMe.from_readme(__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE							)
																		readme.validate()
@pytest.mark.parametrize(
    '''readme_md, expected_error'''      ,      [
        (README_MULTIPLE_SAME_HEADING_1, EXPECTED_ERROR_README_MULTIPLE_SAME_HEADING_1),
    ]      ,      )
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: Tuple      ,      __SCREAMING_SNAKE_CASE					: Optional[Any]							):



						"""simple docstring"""





						with tempfile.TemporaryDirectory() as tmp_dir:
												lowercase_	:     Dict													=       Path(__SCREAMING_SNAKE_CASE							) / '''README.md'''
												with open(__SCREAMING_SNAKE_CASE      ,      '''w+'''							) as readme_file:
																		readme_file.write(__SCREAMING_SNAKE_CASE							)
												lowercase_	:     Tuple													=       expected_error.format(path=__SCREAMING_SNAKE_CASE							)
												with pytest.raises(__SCREAMING_SNAKE_CASE      ,      match=re.escape(__SCREAMING_SNAKE_CASE							)							):
																		ReadMe.from_readme(__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE							)




@pytest.mark.parametrize(
    '''readme_md,'''      ,      [
        (README_MULTIPLE_SAME_HEADING_1),
    ]      ,      )
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: Tuple							):



						"""simple docstring"""





						with tempfile.TemporaryDirectory() as tmp_dir:
												lowercase_	:     Optional[int]													=       Path(__SCREAMING_SNAKE_CASE							) / '''README.md'''
												with open(__SCREAMING_SNAKE_CASE      ,      '''w+'''							) as readme_file:
																		readme_file.write(__SCREAMING_SNAKE_CASE							)
												ReadMe.from_readme(__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE      ,      suppress_parsing_errors=__SCREAMING_SNAKE_CASE							)



