






from manim import *







class 		_A						( UpperCAmelCase_ ):

  def    a					(    self						:	str			):
     """simple docstring"""

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

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

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

     __UpperCamelCase	:			Any					=					[mem.copy() for i in range(6			)]
     __UpperCamelCase	:			int					=					VGroup(*lowerCamelCase__			).arrange(lowerCamelCase__   ,				buff=0			)

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

     __UpperCamelCase	:			Dict					=					[]
     __UpperCamelCase	:			Optional[Any]					=					[]
     __UpperCamelCase	:			List[str]					=					[]

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

        __UpperCamelCase	:			Dict					=					Rectangle(height=0.46 / 4   ,				width=0.46 / 3			).set_stroke(width=0.0			).set_fill(lowerCamelCase__   ,				opacity=0.7			)

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

     self.add(*lowerCamelCase__   ,				*lowerCamelCase__   ,				*lowerCamelCase__			)

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

     __UpperCamelCase	:			int					=					Text("""Loaded Checkpoint"""   ,				font_size=24			)
     __UpperCamelCase	:			List[Any]					=					Group(lowerCamelCase__   ,				lowerCamelCase__			).arrange(lowerCamelCase__   ,				buff=0.5   ,				aligned_edge=lowerCamelCase__			)
     checkpoint.move_to([3, 0.5, 0]			)

     self.add(lowerCamelCase__			)

     __UpperCamelCase	:			Dict					=					[]
     __UpperCamelCase	:			Tuple					=					[]

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

        __UpperCamelCase	:			Tuple					=					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(lowerCamelCase__			)
     self.add(*lowerCamelCase__   ,				*lowerCamelCase__			)

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

     __UpperCamelCase	:			Optional[int]					=					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(lowerCamelCase__   ,				lowerCamelCase__			)

     __UpperCamelCase	:			List[Any]					=					MarkupText(
         f'<span fgcolor=\'{BLUE}\'>●</span> Checkpoint'   ,				font_size=18   ,				)

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

     __UpperCamelCase	:			Union[str, Any]					=					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]			)

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

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

     self.play(FadeOut(lowerCamelCase__			)			)

     __UpperCamelCase	:			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(lowerCamelCase__   ,				run_time=3			)			)

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

     self.wait()











from collections.abc import Iterable
from typing import Generic, TypeVar

UpperCamelCase    							=      TypeVar('_T')







class 		_A						( Generic[_T] ):

  def __init__(    self						:	int   ,				lowerCamelCase__						:	Iterable[_T] | None = None			):
     """simple docstring"""

     __UpperCamelCase	:			list[_T]					=					list(iterable or []			)
     __UpperCamelCase	:			list[_T]					=					[]

  def __len__(    self						:	str			):
     """simple docstring"""

     return len(self._stacka			) + len(self._stacka			)

  def __repr__(    self						:	Dict			):
     """simple docstring"""

     return f'Queue({tuple(self._stacka[::-1] + self._stacka			)})'

  def    a					(    self						:	Union[str, Any]   ,				lowerCamelCase__						:	_T			):
     """simple docstring"""

     self._stacka.append(lowerCamelCase__			)

  def    a					(    self						:	Union[str, Any]			):
     """simple docstring"""

     __UpperCamelCase	:			Any					=					self._stacka.pop
     __UpperCamelCase	:			int					=					self._stacka.append

     if not self._stacka:
        while self._stacka:
           stacka_append(stacka_pop()			)

     if not self._stacka:
        raise IndexError("""Queue is empty"""			)
     return self._stacka.pop()


if __name__ == "__main__":
       from doctest import testmod

       testmod()



