






from manim import *


class   __SCREAMING_SNAKE_CASE(	a_	):
							def lowerCAmelCase_ (     self:      List[str]						)		->		Any:
											snake_case__									=     Rectangle(height=0.5       ,	width=0.5						)
											snake_case__									=     Rectangle(height=0.25       ,	width=0.25						)
											snake_case__									=     Rectangle(height=0.46       ,	width=0.46						).set_stroke(width=0						)

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

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

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

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

											snake_case__									=     []
											snake_case__									=     []
											snake_case__									=     []

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

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

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

											self.add(*UpperCamelCase       ,	*UpperCamelCase       ,	*UpperCamelCase						)

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

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

											self.add(UpperCamelCase						)

											snake_case__									=     []
											snake_case__									=     []

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

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

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

											snake_case__									=     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(UpperCamelCase       ,	UpperCamelCase						)

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

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

											snake_case__									=     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]						)

											snake_case__									=     [meta_mem.copy() for i in range(6						)]
											snake_case__									=     [meta_mem.copy() for i in range(6						)]
											snake_case__									=     VGroup(*UpperCamelCase						).arrange(UpperCamelCase       ,	buff=0						)
											snake_case__									=     VGroup(*UpperCamelCase						).arrange(UpperCamelCase       ,	buff=0						)
											snake_case__									=     VGroup(UpperCamelCase       ,	UpperCamelCase						).arrange(UpperCamelCase       ,	buff=0						)
											snake_case__									=     Text('Disk'       ,	font_size=24						)
											snake_case__									=     Group(UpperCamelCase       ,	UpperCamelCase						).arrange(UpperCamelCase       ,	buff=0.5       ,	aligned_edge=UpperCamelCase						)
											disk.move_to([-4.0, -1.25, 0]						)
											self.play(Write(UpperCamelCase       ,	run_time=3						)       ,	Write(UpperCamelCase       ,	run_time=1						)       ,	Create(UpperCamelCase       ,	run_time=1						)						)

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

											self.play(FadeOut(UpperCamelCase						)						)

											snake_case__									=     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(UpperCamelCase       ,	run_time=3						)						)

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

											self.wait()












from __future__ import annotations

from collections.abc import Iterator
from typing import Any


class   __SCREAMING_SNAKE_CASE:
							def __init__(     self:      int       ,	UpperCamelCase:      Any						)		->		List[Any]:
											snake_case__									=     data
											snake_case__									=     None


class   __SCREAMING_SNAKE_CASE:
							def __init__(     self:      Dict						)		->		Optional[Any]:
											snake_case__									=     None
											snake_case__									=     None
							def __iter__(     self:      Optional[int]						)		->		Iterator[Any]:
											snake_case__									=     self.head
											while self.head:
															yield node.data
															snake_case__									=     node.next
															if node == self.head:
																			break
							def __len__(     self:      int						)		->		int:
											return sum(1 for _ in self						)
							def __repr__(     self:      int						)		->		Optional[int]:
											return "->".join(str(UpperCamelCase						) for item in iter(self						)						)
							def lowerCAmelCase_ (     self:      Union[str, Any]       ,	UpperCamelCase:      Any						)		->		None:
											self.insert_nth(len(self						)       ,	UpperCamelCase						)
							def lowerCAmelCase_ (     self:      Tuple       ,	UpperCamelCase:      Any						)		->		None:
											self.insert_nth(0       ,	UpperCamelCase						)
							def lowerCAmelCase_ (     self:      int       ,	UpperCamelCase:      int       ,	UpperCamelCase:      Any						)		->		None:
											if index < 0 or index > len(self						):
															raise IndexError('list index out of range.'						)
											snake_case__									=     Node(UpperCamelCase						)
											if self.head is None:
															snake_case__									=     new_node  # first node points itself
															snake_case__									=     snake_case__									=     new_node
											elif index == 0:  # insert at head
															snake_case__									=     self.head
															snake_case__									=     snake_case__									=     new_node
											else:
															snake_case__									=     self.head
															for _ in range(index - 1						):
																			snake_case__									=     temp.next
															snake_case__									=     temp.next
															snake_case__									=     new_node
															if index == len(self						) - 1:  # insert at tail
																			snake_case__									=     new_node
							def lowerCAmelCase_ (     self:      Optional[int]						)		->		Union[str, Any]:
											return self.delete_nth(0						)
							def lowerCAmelCase_ (     self:      Union[str, Any]						)		->		Any:
											return self.delete_nth(len(self						) - 1						)
							def lowerCAmelCase_ (     self:      str       ,	UpperCamelCase:      int = 0						)		->		Any:
											if not 0 <= index < len(self						):
															raise IndexError('list index out of range.'						)
											snake_case__									=     self.head
											if self.head == self.tail:  # just one node
															snake_case__									=     snake_case__									=     None
											elif index == 0:  # delete head node
															snake_case__									=     self.tail.next.next
															snake_case__									=     self.head.next
											else:
															snake_case__									=     self.head
															for _ in range(index - 1						):
																			snake_case__									=     temp.next
															snake_case__									=     temp.next
															snake_case__									=     temp.next.next
															if index == len(self						) - 1:  # delete at tail
																			snake_case__									=     temp
											return delete_node.data


							def lowerCAmelCase_ (     self:      Union[str, Any]						)		->		bool:
											return len(self						) == 0


def      a_ (      )			->			None:







				"""simple docstring"""
				snake_case__									=     CircularLinkedList()
				assert len(_A  ) == 0
				assert circular_linked_list.is_empty() is True
				assert str(_A  ) == ""

				try:
								circular_linked_list.delete_front()
								raise AssertionError  # This should not happen
				except IndexError:
								assert True  # This should happen

				try:
								circular_linked_list.delete_tail()
								raise AssertionError  # This should not happen
				except IndexError:
								assert True  # This should happen

				try:
								circular_linked_list.delete_nth(-1  )
								raise AssertionError
				except IndexError:
								assert True

				try:
								circular_linked_list.delete_nth(0  )
								raise AssertionError
				except IndexError:
								assert True

				assert circular_linked_list.is_empty() is True
				for i in range(5  ):
								assert len(_A  ) == i
								circular_linked_list.insert_nth(_A      ,   i + 1  )
				assert str(_A  ) == "->".join(str(_A  ) for i in range(1      ,   6  )  )

				circular_linked_list.insert_tail(6  )
				assert str(_A  ) == "->".join(str(_A  ) for i in range(1      ,   7  )  )
				circular_linked_list.insert_head(0  )
				assert str(_A  ) == "->".join(str(_A  ) for i in range(0      ,   7  )  )

				assert circular_linked_list.delete_front() == 0
				assert circular_linked_list.delete_tail() == 6
				assert str(_A  ) == "->".join(str(_A  ) for i in range(1      ,   6  )  )
				assert circular_linked_list.delete_nth(2  ) == 3

				circular_linked_list.insert_nth(2      ,   3  )
				assert str(_A  ) == "->".join(str(_A  ) for i in range(1      ,   6  )  )

				assert circular_linked_list.is_empty() is False


if __name__ == "__main__":
							import doctest

							doctest.testmod()




