






from collections import Counter
from pathlib import Path
from typing import Optional, Tuple

import yaml


class       __lowercase      (	yaml.SafeLoader  ):







     '''simple docstring'''




     def 		lowerCAmelCase_     (				self       :			Tuple ,	UpperCamelCase_       :			Tuple				):


         """simple docstring"""



         __A         =	[self.constructed_objects[key_node] for key_node, _ in node.value]
         __A         =	[tuple(UpperCamelCase_				) if isinstance(UpperCamelCase_ ,	UpperCamelCase_				) else key for key in keys]
         __A         =	Counter(UpperCamelCase_				)
         __A         =	[key for key in counter if counter[key] > 1]
         if duplicate_keys:
             raise TypeError(F"Got duplicate yaml keys: {duplicate_keys}"				)





     def 		lowerCAmelCase_     (				self       :			Optional[Any] ,	UpperCamelCase_       :			Dict ,	UpperCamelCase_       :			Optional[int]=False				):


         """simple docstring"""



         __A         =	super().construct_mapping(UpperCamelCase_ ,	deep=UpperCamelCase_				)
         self._check_no_duplicates_on_constructed_node(UpperCamelCase_				)
         return mapping



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			str    )						->      Tuple[Optional[str], str]:





    """simple docstring"""

    __A         =	list(readme_content.splitlines()    )
    if full_content and full_content[0] == "---" and "---" in full_content[1:]:
        __A         =	full_content[1:].index("""---"""    ) + 1
        __A         =	"""\n""".join(full_content[1:sep_idx]    )
        return yamlblock, "\n".join(full_content[sep_idx + 1 :]    )

    return None, "\n".join(__lowercase    )


class       __lowercase      (	lowercase_  ):







     '''simple docstring'''
     SCREAMING_SNAKE_CASE   						=				{"train_eval_index"}  # train-eval-index in the YAML metadata




     @classmethod
     def 		lowerCAmelCase_     (				cls       :			int ,	UpperCamelCase_       :			Path				):


         """simple docstring"""



         with open(UpperCamelCase_ ,	encoding="""utf-8"""				) as readme_file:
             __A    ,	__A         =	_split_yaml_from_readme(readme_file.read()				)
         if yaml_string is not None:
             return cls.from_yaml_string(UpperCamelCase_				)
         else:
             return cls()




     def 		lowerCAmelCase_     (				self       :			Any ,	UpperCamelCase_       :			Path				):


         """simple docstring"""



         if path.exists():
             with open(UpperCamelCase_ ,	encoding="""utf-8"""				) as readme_file:
                 __A         =	readme_file.read()
         else:
             __A         =	None
         __A         =	self._to_readme(UpperCamelCase_				)
         with open(UpperCamelCase_ ,	"""w""" ,	encoding="""utf-8"""				) as readme_file:
             readme_file.write(UpperCamelCase_				)




     def 		lowerCAmelCase_     (				self       :			str ,	UpperCamelCase_       :			Optional[str] = None				):


         """simple docstring"""



         if readme_content is not None:
             __A    ,	__A         =	_split_yaml_from_readme(UpperCamelCase_				)
             __A         =	"""---\n""" + self.to_yaml_string() + """---\n""" + content
         else:
             __A         =	"""---\n""" + self.to_yaml_string() + """---\n"""
         return full_content




     @classmethod
     def 		lowerCAmelCase_     (				cls       :			Optional[Any] ,	UpperCamelCase_       :			str				):


         """simple docstring"""



         __A         =	yaml.load(UpperCamelCase_ ,	Loader=_NoDuplicateSafeLoader				) or {}

         # Convert the YAML keys to DatasetMetadata fields
         __A         =	{
             (key.replace("""-""" ,	"""_"""				) if key.replace("""-""" ,	"""_"""				) in cls._FIELDS_WITH_DASHES else key): value
             for key, value in metadata_dict.items()
         }
         return cls(**UpperCamelCase_				)





     def 		lowerCAmelCase_     (				self       :			List[Any]				):


         """simple docstring"""



         return yaml.safe_dump(
             {
                 (key.replace("""_""" ,	"""-"""				) if key in self._FIELDS_WITH_DASHES else key): value
                 for key, value in self.items()
             } ,	sort_keys=UpperCamelCase_ ,	allow_unicode=UpperCamelCase_ ,	encoding="""utf-8""" ,	).decode("""utf-8"""				)
__a      :       Tuple				  =   {
    "image-classification": [],
    "translation": [],
    "image-segmentation": [],
    "fill-mask": [],
    "automatic-speech-recognition": [],
    "token-classification": [],
    "sentence-similarity": [],
    "audio-classification": [],
    "question-answering": [],
    "summarization": [],
    "zero-shot-classification": [],
    "table-to-text": [],
    "feature-extraction": [],
    "other": [],
    "multiple-choice": [],
    "text-classification": [],
    "text-to-image": [],
    "text2text-generation": [],
    "zero-shot-image-classification": [],
    "tabular-classification": [],
    "tabular-regression": [],
    "image-to-image": [],
    "tabular-to-text": [],
    "unconditional-image-generation": [],
    "text-retrieval": [],
    "text-to-speech": [],
    "object-detection": [],
    "audio-to-audio": [],
    "text-generation": [],
    "conversational": [],
    "table-question-answering": [],
    "visual-question-answering": [],
    "image-to-text": [],
    "reinforcement-learning": [],
    "voice-activity-detection": [],
    "time-series-forecasting": [],
    "document-question-answering": [],
}


if __name__ == "__main__":
  from argparse import ArgumentParser

  __a      :       List[Any]				  =   ArgumentParser(usage="Validate the yaml metadata block of a README.md file.")
  ap.add_argument("readme_filepath")
  __a      :       Union[str, Any]				  =   ap.parse_args()

  __a      :       List[Any]				  =   Path(args.readme_filepath)
  __a      :       int				  =   DatasetMetadata.from_readme(readme_filepath)
  print(dataset_metadata)
  dataset_metadata.to_readme(readme_filepath)














__a      :       List[Any]				  =   8.3_1_4_4_5_9_8



def 			_SCREAMING_SNAKE_CASE						( __lowercase   :			float			,				__lowercase   :			float    )						->      float:





    """simple docstring"""

    if temperature < 0:
        raise Exception("""Temperature cannot be less than 0 K"""    )
    if molar_mass <= 0:
        raise Exception("""Molar mass cannot be less than or equal to 0 kg/mol"""    )
    else:
        return (3 * UNIVERSAL_GAS_CONSTANT * temperature / molar_mass) ** 0.5


if __name__ == "__main__":
  import doctest

  # run doctest
  doctest.testmod()

  # example
  __a      :       int				  =   300
  __a      :       int				  =   28
  __a      :       int				  =   rms_speed_of_molecule(temperature, molar_mass)
  print(f"""Vrms of Nitrogen gas at 300 K is {vrms} m/s""")




