



"""simple docstring"""

import os

import pytest
import yaml

from datasets.features.features import Features, Value
from datasets.info import DatasetInfo, DatasetInfosDict





@pytest.mark.parametrize(
    """files"""  ,       [
        ["""full:README.md""", """dataset_infos.json"""],
        ["""empty:README.md""", """dataset_infos.json"""],
        ["""dataset_infos.json"""],
        ["""full:README.md"""],
    ]  ,       )
def       __magic_name__    (   _lowerCamelCase				: Optional[Any]  ,       _lowerCamelCase				: Any					):
							__a		:		Dict									=       tmp_path_factory.mktemp("""dset_infos_dir"""					)
							if "full:README.md" in files:
														with open(dataset_infos_dir / """README.md"""  ,       """w"""					) as f:
																					f.write("""---\ndataset_info:\n  dataset_size: 42\n---"""					)
							if "empty:README.md" in files:
														with open(dataset_infos_dir / """README.md"""  ,       """w"""					) as f:
																					f.write(""""""					)
    # we want to support dataset_infos.json for backward compatibility
							if "dataset_infos.json" in files:
														with open(dataset_infos_dir / """dataset_infos.json"""  ,       """w"""					) as f:
																					f.write("""{\"default\": {\"dataset_size\": 42}}"""					)
							__a		:		List[str]									=       DatasetInfosDict.from_directory(_lowerCamelCase					)
							assert dataset_infos
							assert dataset_infos["default"].dataset_size == 4_2





@pytest.mark.parametrize(
    """dataset_info"""  ,       [
        DatasetInfo(),
        DatasetInfo(
            description="""foo"""  ,       features=Features({"""a""": Value("""int32"""					)}					)  ,       builder_name="""builder"""  ,       config_name="""config"""  ,       version="""1.0.0"""  ,       splits=[{"""name""": """train"""}]  ,       download_size=4_2  ,       ),
    ]  ,       )
def       __magic_name__    (   _lowerCamelCase				: List[Any]  ,       _lowerCamelCase				: DatasetInfo					):
							__a		:		str									=       str(_lowerCamelCase					)
							dataset_info.write_to_directory(_lowerCamelCase					)
							__a		:		List[str]									=       DatasetInfo.from_directory(_lowerCamelCase					)
							assert dataset_info == reloaded
							assert os.path.exists(os.path.join(_lowerCamelCase  ,       """dataset_info.json"""					)					)





def       __magic_name__    (   ):
							__a		:		Dict									=       DatasetInfo(
							    description="""foo"""  ,       citation="""bar"""  ,       homepage="""https://foo.bar"""  ,       license="""CC0"""  ,       features=Features({"""a""": Value("""int32"""					)}					)  ,       post_processed={}  ,       supervised_keys=()  ,       task_templates=[]  ,       builder_name="""builder"""  ,       config_name="""config"""  ,       version="""1.0.0"""  ,       splits=[{"""name""": """train""", """num_examples""": 4_2}]  ,       download_checksums={}  ,       download_size=1_3_3_7  ,       post_processing_size=4_4_2  ,       dataset_size=1_2_3_4  ,       size_in_bytes=1_3_3_7 + 4_4_2 + 1_2_3_4  ,       )
							__a		:		List[str]									=       dataset_info._to_yaml_dict()
							assert sorted(_lowerCamelCase					) == sorted(DatasetInfo._INCLUDED_INFO_IN_YAML					)
							for key in DatasetInfo._INCLUDED_INFO_IN_YAML:
														assert key in dataset_info_yaml_dict
														assert isinstance(dataset_info_yaml_dict[key]  ,       (list, dict, int, str)					)
							__a		:		Optional[Any]									=       yaml.safe_dump(_lowerCamelCase					)
							__a		:		List[Any]									=       yaml.safe_load(_lowerCamelCase					)
							assert dataset_info_yaml_dict == reloaded





def       __magic_name__    (   ):
							__a		:		Union[str, Any]									=       DatasetInfo()
							__a		:		List[str]									=       dataset_info._to_yaml_dict()
							assert dataset_info_yaml_dict == {}







@pytest.mark.parametrize(
    """dataset_infos_dict"""  ,       [
        DatasetInfosDict(),
        DatasetInfosDict({"""default""": DatasetInfo()}					),
        DatasetInfosDict({"""my_config_name""": DatasetInfo()}					),
        DatasetInfosDict(
            {
                """default""": DatasetInfo(
                    description="""foo"""  ,       features=Features({"""a""": Value("""int32"""					)}					)  ,       builder_name="""builder"""  ,       config_name="""config"""  ,       version="""1.0.0"""  ,       splits=[{"""name""": """train"""}]  ,       download_size=4_2  ,       )
            }					),
        DatasetInfosDict(
            {
                """v1""": DatasetInfo(dataset_size=4_2					),
                """v2""": DatasetInfo(dataset_size=1_3_3_7					),
            }					),
    ]  ,       )
def       __magic_name__    (   _lowerCamelCase				: Tuple  ,       _lowerCamelCase				: DatasetInfosDict					):
							__a		:		List[str]									=       str(_lowerCamelCase					)
							dataset_infos_dict.write_to_directory(_lowerCamelCase					)
							__a		:		Union[str, Any]									=       DatasetInfosDict.from_directory(_lowerCamelCase					)

							# the config_name of the dataset_infos_dict take over the attribute
							for config_name, dataset_info in dataset_infos_dict.items():
														__a		:		Optional[int]									=       config_name
														# the yaml representation doesn't include fields like description or citation
														# so we just test that we can recover what we can from the yaml
														__a		:		str									=       DatasetInfo._from_yaml_dict(dataset_info._to_yaml_dict()					)
							assert dataset_infos_dict == reloaded

							if dataset_infos_dict:
														assert os.path.exists(os.path.join(_lowerCamelCase  ,       """README.md"""					)					)






"""simple docstring"""

from manim import *




class SCREAMING_SNAKE_CASE__					(		__snake_case      ):



						def     lowerCAmelCase__(self							):





													'''simple docstring'''

													__a		:		List[str]									=       Rectangle(height=0.5						,     width=0.5							)
													__a		:		Union[str, Any]									=       Rectangle(height=0.25						,     width=0.25							)
													__a		:		Dict									=       Rectangle(height=0.46						,     width=0.46							).set_stroke(width=0							)

													__a		:		Dict									=       [mem.copy() for i in range(6							)]
													__a		:		str									=       [mem.copy() for i in range(6							)]
													__a		:		Tuple									=       VGroup(*_lowercase							).arrange(_lowercase						,     buff=0							)
													__a		:		List[Any]									=       VGroup(*_lowercase							).arrange(_lowercase						,     buff=0							)
													__a		:		List[Any]									=       VGroup(_lowercase						,     _lowercase							).arrange(_lowercase						,     buff=0							)
													__a		:		Union[str, Any]									=       Text("""CPU"""						,     font_size=24							)
													__a		:		Dict									=       Group(_lowercase						,     _lowercase							).arrange(_lowercase						,     buff=0.5						,     aligned_edge=_lowercase							)
													cpu.move_to([-2.5, -0.5, 0]							)
													self.add(_lowercase							)

													__a		:		Optional[Any]									=       [mem.copy() for i in range(4							)]
													__a		:		Dict									=       VGroup(*_lowercase							).arrange(_lowercase						,     buff=0							)
													__a		:		List[str]									=       Text("""GPU"""						,     font_size=24							)
													__a		:		Any									=       Group(_lowercase						,     _lowercase							).arrange(_lowercase						,     buff=0.5						,     aligned_edge=_lowercase							)
													gpu.move_to([-1, -1, 0]							)
													self.add(_lowercase							)

													__a		:		List[Any]									=       [mem.copy() for i in range(6							)]
													__a		:		Any									=       VGroup(*_lowercase							).arrange(_lowercase						,     buff=0							)

													__a		:		Optional[Any]									=       Text("""Model"""						,     font_size=24							)
													__a		:		Any									=       Group(_lowercase						,     _lowercase							).arrange(_lowercase						,     buff=0.5						,     aligned_edge=_lowercase							)
													model.move_to([3, -1.0, 0]							)
													self.add(_lowercase							)

													__a		:		Tuple									=       []
													__a		:		Tuple									=       []
													__a		:		Optional[int]									=       []

													for i, rect in enumerate(_lowercase							):
																				rect.set_stroke(_lowercase							)

																				__a		:		str									=       Rectangle(height=0.46 / 4						,     width=0.46 / 3							).set_stroke(width=0.0							).set_fill(_lowercase						,     opacity=0.7							)

																				if i == 0:
																											cpu_target.next_to(cpu_left_col_base[0].get_corner(DOWN + LEFT							)						,     buff=0.02						,     direction=_lowercase							)
																											cpu_target.set_x(cpu_target.get_x() + 0.1							)
																				elif i == 3:
																											cpu_target.next_to(model_cpu_arr[0]						,     direction=_lowercase						,     buff=0.0							)
																				else:
																											cpu_target.next_to(model_cpu_arr[i - 1]						,     direction=_lowercase						,     buff=0.0							)
																				self.add(_lowercase							)
																				model_cpu_arr.append(_lowercase							)

													self.add(*_lowercase						,     *_lowercase						,     *_lowercase							)

													__a		:		Optional[Any]									=       [mem.copy() for i in range(6							)]
													__a		:		Union[str, Any]									=       VGroup(*_lowercase							).arrange(_lowercase						,     buff=0							)

													__a		:		Any									=       Text("""Loaded Checkpoint"""						,     font_size=24							)
													__a		:		str									=       Group(_lowercase						,     _lowercase							).arrange(_lowercase						,     buff=0.5						,     aligned_edge=_lowercase							)
													checkpoint.move_to([3, 0.5, 0]							)

													self.add(_lowercase							)

													__a		:		Dict									=       []
													__a		:		int									=       []

													for i, rect in enumerate(_lowercase							):
																				__a		:		List[str]									=       fill.copy().set_fill(_lowercase						,     opacity=0.7							)
																				target.move_to(_lowercase							)
																				ckpt_arr.append(_lowercase							)

																				__a		:		Union[str, Any]									=       target.copy()
																				if i < 5:
																											cpu_target.move_to(cpu_left_col_base[i + 1]							)
																				else:
																											cpu_target.move_to(cpu_right_col_base[i - 5]							)
																				ckpt_cpu_arr.append(_lowercase							)
													self.add(*_lowercase						,     *_lowercase							)

													__a		:		List[str]									=       Square(side_length=2.2							)
													key.move_to([-5, 2, 0]							)

													__a		:		List[Any]									=       MarkupText(
													    F'''<b>Key:</b>\n\n<span fgcolor=\'{YELLOW}\'>●</span> Empty Model'''						,     font_size=18						,     )

													key_text.move_to([-5, 2.4, 0]							)

													self.add(_lowercase						,     _lowercase							)

													__a		:		str									=       MarkupText(
													    F'''<span fgcolor=\'{BLUE}\'>●</span> Checkpoint'''						,     font_size=18						,     )

													blue_text.next_to(_lowercase						,     DOWN * 2.4						,     aligned_edge=key_text.get_left()							)
													self.add(_lowercase							)

													__a		:		Optional[int]									=       MarkupText(
													    F'''Based on the passed in configuration, weights are stored in\na variety of np.memmaps on disk or to a particular device.'''						,     font_size=24						,     )
													step_a.move_to([2, 2, 0]							)

													__a		:		List[Any]									=       [meta_mem.copy() for i in range(6							)]
													__a		:		Optional[int]									=       [meta_mem.copy() for i in range(6							)]
													__a		:		List[Any]									=       VGroup(*_lowercase							).arrange(_lowercase						,     buff=0							)
													__a		:		List[str]									=       VGroup(*_lowercase							).arrange(_lowercase						,     buff=0							)
													__a		:		Tuple									=       VGroup(_lowercase						,     _lowercase							).arrange(_lowercase						,     buff=0							)
													__a		:		Dict									=       Text("""Disk"""						,     font_size=24							)
													__a		:		Dict									=       Group(_lowercase						,     _lowercase							).arrange(_lowercase						,     buff=0.5						,     aligned_edge=_lowercase							)
													disk.move_to([-4.0, -1.25, 0]							)
													self.play(Write(_lowercase						,     run_time=3							)						,     Write(_lowercase						,     run_time=1							)						,     Create(_lowercase						,     run_time=1							)							)

													__a		:		Optional[Any]									=       []
													for i, rect in enumerate(_lowercase							):
																				__a		:		List[str]									=       rect.copy()
																				target.generate_target()
																				target.target.move_to(disk_left_col_base[i]							).scale(0.5							)
																				animations.append(MoveToTarget(_lowercase						,     run_time=1.5							)							)
													self.play(*_lowercase							)

													self.play(FadeOut(_lowercase							)							)

													__a		:		List[str]									=       MarkupText(F'''Then, the checkpoint is removed from memory\nthrough garbage collection.'''						,     font_size=24							)
													step_a.move_to([2, 2, 0]							)

													self.play(Write(_lowercase						,     run_time=3							)							)

													self.play(
													    FadeOut(_lowercase						,     _lowercase						,     *_lowercase						,     *_lowercase							)						,     )

													self.wait()

