

from manim import *

class 							UpperCAmelCase_						(     __lowercase  ):
							"""simple docstring"""







							def 							__lowercase							(     self			)       ->       str:
												_a      :       Union[str, Any]   =						Rectangle(height=0.5			,				width=0.5			)
												_a      :       List[str]   =						Rectangle(height=0.46			,				width=0.46			).set_stroke(width=0			)

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

												_a      :       int   =						[mem.copy() for i in range(4			)]
												_a      :       List[Any]   =						VGroup(*_a			).arrange(_a			,				buff=0			)
												_a      :       Any   =						Text('''GPU'''			,				font_size=2_4			)
												_a      :       int   =						Group(_a			,				_a			).arrange(_a			,				buff=0.5			,				aligned_edge=_a			)
												gpu.move_to([-1, -1, 0]			)
												self.add(_a			)

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

												_a      :       Any   =						Text('''Model'''			,				font_size=2_4			)
												_a      :       str   =						Group(_a			,				_a			).arrange(_a			,				buff=0.5			,				aligned_edge=_a			)
												model.move_to([3, -1.0, 0]			)
												self.add(_a			)

												_a      :       List[Any]   =						[]
												for i, rect in enumerate(_a			):
																	rect.set_stroke(_a			)
																	# target = fill.copy().set_fill(YELLOW, opacity=0.7)
																	# target.move_to(rect)
																	# self.add(target)

																	_a      :       Tuple   =						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(cpu_targs[0]			,				direction=_a			,				buff=0.0			)
																	else:
																						cpu_target.next_to(cpu_targs[i - 1]			,				direction=_a			,				buff=0.0			)
																	self.add(_a			)
																	cpu_targs.append(_a			)

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

												_a      :       Dict   =						Text('''Loaded Checkpoint'''			,				font_size=2_4			)
												_a      :       str   =						Group(_a			,				_a			).arrange(_a			,				aligned_edge=_a			,				buff=0.4			)
												checkpoint.move_to([3, 0.5, 0]			)

												_a      :       Tuple   =						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=1_8			,				)

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

												self.add(_a			,				_a			)

												_a      :       List[str]   =						MarkupText(
												    F"""<span fgcolor='{BLUE}'>●</span> Checkpoint"""			,				font_size=1_8			,				)

												blue_text.next_to(_a			,				DOWN * 2.4			,				aligned_edge=key_text.get_left()			)

												_a      :       List[str]   =						MarkupText(
												    F"""Next, a <i><span fgcolor=\"{BLUE}\">second</span></i> model is loaded into memory,\nwith the weights of a <span fgcolor=\"{BLUE}\">single shard</span>."""			,				font_size=2_4			,				)
												step_a.move_to([2, 2, 0]			)
												self.play(Write(_a			)			,				Write(_a			)			)

												self.play(Write(_a			,				run_time=1			)			,				Create(_a			,				run_time=1			)			)

												_a      :       Optional[Any]   =						[]
												_a      :       List[Any]   =						[]
												for i, rect in enumerate(_a			):
																	_a      :       List[str]   =						fill.copy().set_fill(_a			,				opacity=0.7			)
																	target.move_to(_a			)
																	first_animations.append(GrowFromCenter(_a			,				run_time=1			)			)

																	_a      :       List[Any]   =						target.copy()
																	cpu_target.generate_target()
																	if i < 5:
																						cpu_target.target.move_to(cpu_left_col_base[i + 1]			)
																	else:
																						cpu_target.target.move_to(cpu_right_col_base[i - 5]			)
																	second_animations.append(MoveToTarget(_a			,				run_time=1.5			)			)

												self.play(*_a			)
												self.play(*_a			)
												self.wait()










class 		snake_case_   :







	'''simple docstring'''




	def __init__(						self							:     Dict					,      __lowerCamelCase							:     int					,      __lowerCamelCase							:     Optional[Any]=None					,      __lowerCamelCase							:     Optional[Any]=None   )       -> Dict:

			'''simple docstring'''




			__lowercase											=     data
			__lowercase											=     previous
			__lowercase											=     next_node




	def __str__(						self							:     int   )       -> str:

			'''simple docstring'''




			return F"{self.data}"




	def    UpperCAmelCase			(						self							:     int   )       -> int:

			'''simple docstring'''




			return self.data




	def    UpperCAmelCase			(						self							:     Tuple   )       -> Optional[int]:

			'''simple docstring'''




			return self.next






	def    UpperCAmelCase			(						self							:     Optional[int]   )       -> Any:

			'''simple docstring'''




			return self.previous





class 		snake_case_   :







	'''simple docstring'''




	def __init__(						self							:     Tuple					,      __lowerCamelCase							:     Optional[Any]   )       -> str:

			'''simple docstring'''




			__lowercase											=     head




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

			'''simple docstring'''




			return self






	def    UpperCAmelCase			(						self							:     str   )       -> str:

			'''simple docstring'''




			if not self.current:
					raise StopIteration
			else:
					__lowercase											=     self.current.get_data()
					__lowercase											=     self.current.get_next()
					return value





class 		snake_case_   :







	'''simple docstring'''




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

			'''simple docstring'''




			__lowercase											=     None  # First node in list
			__lowercase											=     None  # Last node in list




	def __str__(						self							:     int   )       -> Any:

			'''simple docstring'''




			__lowercase											=     self.head
			__lowercase											=     []
			while current is not None:
					nodes.append(current.get_data()   )
					__lowercase											=     current.get_next()
			return " ".join(str(__lowerCamelCase   ) for node in nodes   )




	def __contains__(						self							:     Tuple					,      __lowerCamelCase							:     int   )       -> List[Any]:

			'''simple docstring'''




			__lowercase											=     self.head
			while current:
					if current.get_data() == value:
							return True
					__lowercase											=     current.get_next()
			return False




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

			'''simple docstring'''




			return LinkedListIterator(self.head   )




	def    UpperCAmelCase			(						self							:     Any   )       -> str:

			'''simple docstring'''




			if self.head:
					return self.head.get_data()
			return None




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

			'''simple docstring'''




			if self.tail:
					return self.tail.get_data()
			return None




	def    UpperCAmelCase			(						self							:     str					,      __lowerCamelCase							:     Node   )       -> None:

			'''simple docstring'''




			if self.head is None:
					__lowercase											=     node
					__lowercase											=     node
			else:
					self.insert_before_node(self.head					,      __lowerCamelCase   )




	def    UpperCAmelCase			(						self							:     Dict					,      __lowerCamelCase							:     Node   )       -> None:

			'''simple docstring'''




			if self.head is None:
					self.set_head(__lowerCamelCase   )
			else:
					self.insert_after_node(self.tail					,      __lowerCamelCase   )




	def    UpperCAmelCase			(						self							:     Optional[Any]					,      __lowerCamelCase							:     int   )       -> None:

			'''simple docstring'''




			__lowercase											=     Node(__lowerCamelCase   )
			if self.head is None:
					self.set_head(__lowerCamelCase   )
			else:
					self.set_tail(__lowerCamelCase   )




	def    UpperCAmelCase			(						self							:     int					,      __lowerCamelCase							:     Node					,      __lowerCamelCase							:     Node   )       -> None:

			'''simple docstring'''




			__lowercase											=     node
			__lowercase											=     node.previous

			if node.get_previous() is None:
					__lowercase											=     node_to_insert
			else:
					__lowercase											=     node_to_insert

			__lowercase											=     node_to_insert




	def    UpperCAmelCase			(						self							:     Optional[Any]					,      __lowerCamelCase							:     Node					,      __lowerCamelCase							:     Node   )       -> None:

			'''simple docstring'''




			__lowercase											=     node
			__lowercase											=     node.next

			if node.get_next() is None:
					__lowercase											=     node_to_insert
			else:
					__lowercase											=     node_to_insert

			__lowercase											=     node_to_insert




	def    UpperCAmelCase			(						self							:     List[str]					,      __lowerCamelCase							:     int					,      __lowerCamelCase							:     int   )       -> None:

			'''simple docstring'''




			__lowercase											=     1
			__lowercase											=     Node(__lowerCamelCase   )
			__lowercase											=     self.head
			while node:
					if current_position == position:
							self.insert_before_node(__lowerCamelCase					,      __lowerCamelCase   )
							return
					current_position += 1
					__lowercase											=     node.next
			self.insert_after_node(self.tail					,      __lowerCamelCase   )




	def    UpperCAmelCase			(						self							:     Optional[Any]					,      __lowerCamelCase							:     int   )       -> Node:

			'''simple docstring'''




			__lowercase											=     self.head
			while node:
					if node.get_data() == item:
							return node
					__lowercase											=     node.get_next()
			raise Exception('Node not found'   )




	def    UpperCAmelCase			(						self							:     Optional[Any]					,      __lowerCamelCase							:     List[str]   )       -> Dict:

			'''simple docstring'''




			if (node := self.get_node(__lowerCamelCase   )) is not None:
					if node == self.head:
							__lowercase											=     self.head.get_next()

					if node == self.tail:
							__lowercase											=     self.tail.get_previous()

					self.remove_node_pointers(__lowerCamelCase   )




	@staticmethod
	def    UpperCAmelCase			(						__lowerCamelCase							:     Node   )       -> None:

			'''simple docstring'''




			if node.get_next():
					__lowercase											=     node.previous

			if node.get_previous():
					__lowercase											=     node.next

			__lowercase											=     None
			__lowercase											=     None






	def    UpperCAmelCase			(						self							:     str   )       -> List[str]:

			'''simple docstring'''




			return self.head is None





def  SCREAMING_SNAKE_CASE				(      )		->    None:
		pass


if __name__ == "__main__":
		import doctest

		doctest.testmod()




