




"""simple docstring"""





from manim import *



class      a__				(	__magic_name__   ):


			def       a_     (      self      :    str):


						"""simple docstring"""




						__UpperCAmelCase	: Optional[int]		=					Rectangle(height=0.5      ,  width=0.5)
						__UpperCAmelCase	: int		=					Rectangle(height=0.46      ,  width=0.46).set_stroke(width=0)

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

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

						__UpperCAmelCase	: List[str]		=					[mem.copy() for i in range(6)]
						__UpperCAmelCase	: Optional[int]		=					VGroup(*UpperCamelCase_).arrange(UpperCamelCase_      ,  buff=0)

						__UpperCAmelCase	: int		=					Text("Model"      ,  font_size=24)
						__UpperCAmelCase	: str		=					Group(UpperCamelCase_      ,  UpperCamelCase_).arrange(UpperCamelCase_      ,  buff=0.5      ,  aligned_edge=UpperCamelCase_)
						model.move_to([3, -1.0, 0])
						self.add(UpperCamelCase_)

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

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

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

						__UpperCAmelCase	: Any		=					Text("Loaded Checkpoint"      ,  font_size=24)
						__UpperCAmelCase	: Optional[int]		=					Group(UpperCamelCase_      ,  UpperCamelCase_).arrange(UpperCamelCase_      ,  aligned_edge=UpperCamelCase_      ,  buff=0.4)
						checkpoint.move_to([3, 0.5, 0])

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

						__UpperCAmelCase	: Tuple		=					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_)

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

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

						__UpperCAmelCase	: int		=					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=24      ,  )
						step_a.move_to([2, 2, 0])
						self.play(Write(UpperCamelCase_)      ,  Write(UpperCamelCase_))

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

						__UpperCAmelCase	: Optional[Any]		=					[]
						__UpperCAmelCase	: int		=					[]
						for i, rect in enumerate(UpperCamelCase_):
									__UpperCAmelCase	: Tuple		=					fill.copy().set_fill(UpperCamelCase_      ,  opacity=0.7)
									target.move_to(UpperCamelCase_)
									first_animations.append(GrowFromCenter(UpperCamelCase_      ,  run_time=1))

									__UpperCAmelCase	: str		=					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(UpperCamelCase_      ,  run_time=1.5))

						self.play(*UpperCamelCase_)
						self.play(*UpperCamelCase_)
						self.wait()








"""simple docstring"""





def 					_UpperCamelCase    (			UpperCamelCase							)			->			int:


			"""simple docstring"""

			if not grid or not grid[0]:
						raise TypeError("The grid does not contain the appropriate information"							)

			for cell_n in range(1				,       len(grid[0]							)							):
						grid[0][cell_n] += grid[0][cell_n - 1]
			__UpperCAmelCase	: int		=					grid[0]

			for row_n in range(1				,       len(UpperCamelCase							)							):
						__UpperCAmelCase	: int		=					grid[row_n]
						__UpperCAmelCase	: str		=					fill_row(UpperCamelCase				,       UpperCamelCase							)
						__UpperCAmelCase	: List[str]		=					grid[row_n]

			return grid[-1][-1]

def 					_UpperCamelCase    (			UpperCamelCase				,       UpperCamelCase							)			->			list:


			"""simple docstring"""
			current_row[0] += row_above[0]
			for cell_n in range(1				,       len(UpperCamelCase							)							):
						current_row[cell_n] += min(current_row[cell_n - 1]				,       row_above[cell_n]							)

			return current_row


if __name__ == "__main__":
					import doctest

					doctest.testmod()


