
"""simple docstring"""


from manim import *







class  lowerCAmelCase_ (					_lowercase			):



						'''simple docstring'''


						def   _SCREAMING_SNAKE_CASE					(       self   :					Optional[Any]					)   ->      Optional[int]:
							A        =      Rectangle(height=0.5     ,width=0.5					)
							A        =      Rectangle(height=0.25     ,width=0.25					)
							A        =      Rectangle(height=0.46     ,width=0.46					).set_stroke(width=0					)

							A        =      [mem.copy() for i in range(6					)]
							A        =      [mem.copy() for i in range(6					)]
							A        =      VGroup(*A_					).arrange(A_     ,buff=0					)
							A        =      VGroup(*A_					).arrange(A_     ,buff=0					)
							A        =      VGroup(A_     ,A_					).arrange(A_     ,buff=0					)
							A        =      Text('CPU'     ,font_size=24					)
							A        =      Group(A_     ,A_					).arrange(A_     ,buff=0.5     ,aligned_edge=A_					)
							cpu.move_to([-2.5, -0.5, 0]					)
							self.add(A_					)

							A        =      [mem.copy() for i in range(4					)]
							A        =      VGroup(*A_					).arrange(A_     ,buff=0					)
							A        =      Text('GPU'     ,font_size=24					)
							A        =      Group(A_     ,A_					).arrange(A_     ,buff=0.5     ,aligned_edge=A_					)
							gpu.move_to([-1, -1, 0]					)
							self.add(A_					)

							A        =      [mem.copy() for i in range(6					)]
							A        =      VGroup(*A_					).arrange(A_     ,buff=0					)

							A        =      Text('Model'     ,font_size=24					)
							A        =      Group(A_     ,A_					).arrange(A_     ,buff=0.5     ,aligned_edge=A_					)
							model.move_to([3, -1.0, 0]					)
							self.add(A_					)

							A        =      []
							A        =      []
							A        =      []

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

								A        =      Rectangle(height=0.46 / 4     ,width=0.46 / 3					).set_stroke(width=0.0					).set_fill(A_     ,opacity=0.7					)

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

							self.add(*A_     ,*A_     ,*A_					)

							A        =      [mem.copy() for i in range(6					)]
							A        =      VGroup(*A_					).arrange(A_     ,buff=0					)

							A        =      Text('Loaded Checkpoint'     ,font_size=24					)
							A        =      Group(A_     ,A_					).arrange(A_     ,buff=0.5     ,aligned_edge=A_					)
							checkpoint.move_to([3, 0.5, 0]					)

							self.add(A_					)

							A        =      []
							A        =      []

							for i, rect in enumerate(A_					):
								A        =      fill.copy().set_fill(A_     ,opacity=0.7					)
								target.move_to(A_					)
								ckpt_arr.append(A_					)

								A        =      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(A_					)
							self.add(*A_     ,*A_					)

							A        =      Square(side_length=2.2					)
							key.move_to([-5, 2, 0]					)

							A        =      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(A_     ,A_					)

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

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

							A        =      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        =      [meta_mem.copy() for i in range(6					)]
							A        =      [meta_mem.copy() for i in range(6					)]
							A        =      VGroup(*A_					).arrange(A_     ,buff=0					)
							A        =      VGroup(*A_					).arrange(A_     ,buff=0					)
							A        =      VGroup(A_     ,A_					).arrange(A_     ,buff=0					)
							A        =      Text('Disk'     ,font_size=24					)
							A        =      Group(A_     ,A_					).arrange(A_     ,buff=0.5     ,aligned_edge=A_					)
							disk.move_to([-4.0, -1.25, 0]					)
							self.play(Write(A_     ,run_time=3					)     ,Write(A_     ,run_time=1					)     ,Create(A_     ,run_time=1					)					)

							A        =      []
							for i, rect in enumerate(A_					):
								A        =      rect.copy()
								target.generate_target()
								target.target.move_to(disk_left_col_base[i]					).scale(0.5					)
								animations.append(MoveToTarget(A_     ,run_time=1.5					)					)
							self.play(*A_					)

							self.play(FadeOut(A_					)					)

							A        =      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(A_     ,run_time=3					)					)

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

							self.wait()






import os
from typing import Optional

import fsspec
from fsspec.archive import AbstractArchiveFileSystem
from fsspec.utils import DEFAULT_BLOCK_SIZE



class 					__lowerCAmelCase       (			_a     ):
			lowerCamelCase_     :     int       			=      ''''''
			lowerCamelCase_     :     str       			=      (
			    None  # protocol passed in prefix to the url. ex: "gzip", for gzip://file.txt::http://foo.bar/file.txt.gz
			)
			lowerCamelCase_     :     str       			=      None  # compression type in fsspec. ex: "gzip"
			lowerCamelCase_     :     str       			=      None  # extension of the filename to strip. ex: "".gz" to get file.txt from file.txt.gz






			def __init__(self					,							__magic_name__ = ""					,							__magic_name__ = None					,							__magic_name__ = None					,							**__magic_name__    )     ->   Any:


							'''simple docstring'''



							super().__init__(self					,							**__magic_name__    )
							# always open as "rb" since fsspec can then use the TextIOWrapper to make it work for "r" mode
							snake_case_						:    Union[str, Any]				=  fsspec.open(
							    __magic_name__					,							mode='''rb'''					,							protocol=__magic_name__					,							compression=self.compression					,							client_kwargs={
							        '''requote_redirect_url''': False,  # see https://github.com/huggingface/datasets/pull/5459
							        '''trust_env''': True,  # Enable reading proxy env variables.
							        **(target_options or {}).pop('''client_kwargs'''					,							{}    ),  # To avoid issues if it was already passed.
							    }					,							**(target_options or {})					,							)
							snake_case_						:    Tuple				=  os.path.basename(self.file.path.split('''::'''    )[0]    )
							snake_case_						:    Optional[Any]				=  (
							    self.compressed_name[: self.compressed_name.rindex('''.'''    )]
							    if '''.''' in self.compressed_name
							    else self.compressed_name
							)
							snake_case_						:    Dict				=  None






			@classmethod
			def 			lowerCamelCase  (cls					,							__magic_name__    )     ->   Optional[int]:


							'''simple docstring'''



							return super()._strip_protocol(__magic_name__    ).lstrip('''/'''    )






			def 			lowerCamelCase  (self    )     ->   Union[str, Any]:


							'''simple docstring'''



							if self.dir_cache is None:
											snake_case_						:    Optional[int]				=  {**self.file.fs.info(self.file.path    ), '''name''': self.uncompressed_name}
											snake_case_						:    List[str]				=  {f['''name''']: f}






			def 			lowerCamelCase  (self					,							__magic_name__    )     ->   Optional[Any]:


							'''simple docstring'''



							return self.file.open().read()






			def 			lowerCamelCase  (self					,							__magic_name__					,							__magic_name__ = "rb"					,							__magic_name__=None					,							__magic_name__=True					,							__magic_name__=None					,							**__magic_name__					,							)     ->   int:


							'''simple docstring'''



							snake_case_						:    Union[str, Any]				=  self._strip_protocol(__magic_name__    )
							if mode != "rb":
											raise ValueError(F'''Tried to read with mode {mode} on file {self.file.path} opened with mode \'rb\''''    )
							return self.file.open()




class 					__lowerCAmelCase       (			_a     ):
			lowerCamelCase_     :     Union[str, Any]       			=      '''bz2'''
			lowerCamelCase_     :     Any       			=      '''bz2'''
			lowerCamelCase_     :     int       			=      '''.bz2'''




class 					__lowerCAmelCase       (			_a     ):
			lowerCamelCase_     :     Union[str, Any]       			=      '''gzip'''
			lowerCamelCase_     :     Dict       			=      '''gzip'''
			lowerCamelCase_     :     int       			=      '''.gz'''




class 					__lowerCAmelCase       (			_a     ):
			lowerCamelCase_     :     Any       			=      '''lz4'''
			lowerCamelCase_     :     Any       			=      '''lz4'''
			lowerCamelCase_     :     Optional[Any]       			=      '''.lz4'''




class 					__lowerCAmelCase       (			_a     ):
			lowerCamelCase_     :     Tuple       			=      '''xz'''
			lowerCamelCase_     :     Any       			=      '''xz'''
			lowerCamelCase_     :     int       			=      '''.xz'''




class 					__lowerCAmelCase       (			_a     ):
			lowerCamelCase_     :     Union[str, Any]       			=      '''zstd'''
			lowerCamelCase_     :     Tuple       			=      '''zstd'''
			lowerCamelCase_     :     Any       			=      '''.zst'''






			def __init__(self					,							__magic_name__					,							__magic_name__ = "rb"					,							__magic_name__ = None					,							__magic_name__ = None					,							__magic_name__ = DEFAULT_BLOCK_SIZE					,							**__magic_name__					,							)     ->   Tuple:


							'''simple docstring'''



							super().__init__(
							    fo=__magic_name__					,							mode=__magic_name__					,							target_protocol=__magic_name__					,							target_options=__magic_name__					,							block_size=__magic_name__					,							**__magic_name__					,							)
							# We need to wrap the zstd decompressor to avoid this error in fsspec==2021.7.0 and zstandard==0.15.2:
							#
							# File "/Users/user/.virtualenvs/hf-datasets/lib/python3.7/site-packages/fsspec/core.py", line 145, in open
							#     out.close = close
							# AttributeError: 'zstd.ZstdDecompressionReader' object attribute 'close' is read-only
							#
							# see https://github.com/intake/filesystem_spec/issues/725
							snake_case_						:    Dict				=  self.file.__enter__



							class 					__lowerCAmelCase       :






										def __init__(self					,							__magic_name__    )     ->   List[Any]:


														'''simple docstring'''



														snake_case_						:    str				=  file_






										def __enter__(self    )     ->   List[Any]:


														'''simple docstring'''



														self._file.__enter__()
														return self






										def __exit__(self					,							*__magic_name__					,							**__magic_name__    )     ->   int:


														'''simple docstring'''



														self._file.__exit__(*__magic_name__					,							**__magic_name__    )






										def __iter__(self    )     ->   Optional[int]:


														'''simple docstring'''



														return iter(self._file    )






										def 			lowerCamelCase  (self    )     ->   Union[str, Any]:


														'''simple docstring'''



														return next(self._file    )






										def __getattr__(self					,							__magic_name__    )     ->   str:


														'''simple docstring'''



														return getattr(self._file					,							__magic_name__    )

							def fixed_enter(*__magic_name__					,							**__magic_name__    ):
											return WrappedFile(_enter(*__magic_name__					,							**__magic_name__    )    )

							snake_case_						:    Tuple				=  fixed_enter
