from manim import *



class 			UpperCamelCase					(			__lowercase			):

     '''simple docstring'''

     def 		UpperCamelCase_    (       self    )			->					Any:






           """simple docstring"""
           _lowerCamelCase           =					Rectangle(height=0.5					,					width=0.5    )
           _lowerCamelCase           =					Rectangle(height=0.46					,					width=0.46    ).set_stroke(width=0    )
           _lowerCamelCase           =					Rectangle(height=0.25					,					width=0.25    )

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

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

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

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

           _lowerCamelCase           =					[]
           _lowerCamelCase           =					[]

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

                 _lowerCamelCase           =					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_    )

           _lowerCamelCase           =					[meta_mem.copy() for i in range(6    )]
           _lowerCamelCase           =					[meta_mem.copy() for i in range(6    )]
           _lowerCamelCase           =					VGroup(*A_    ).arrange(A_					,					buff=0    )
           _lowerCamelCase           =					VGroup(*A_    ).arrange(A_					,					buff=0    )
           _lowerCamelCase           =					VGroup(A_					,					A_    ).arrange(A_					,					buff=0    )
           _lowerCamelCase           =					Text('''Disk'''					,					font_size=24    )
           _lowerCamelCase           =					Group(A_					,					A_    ).arrange(A_					,					buff=0.5					,					aligned_edge=A_    )
           disk.move_to([-4.0, -1.25, 0]    )
           self.add(A_					,					A_    )

           _lowerCamelCase           =					[]

           for i in range(6    ):
                 _lowerCamelCase           =					fill.copy().set_fill(A_					,					opacity=0.8    )
                 target.move_to(disk_left_col_base[i]    ).scale(0.5    )
                 cpu_disk_arr.append(A_    )

           self.add(*A_    )

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

           _lowerCamelCase           =					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_    )

           _lowerCamelCase           =					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_    )

           _lowerCamelCase           =					MarkupText(F'The offloaded weights are all sent to the CPU.'					,					font_size=24    )
           step_a.move_to([2, 2, 0]    )

           self.play(Write(A_					,					run_time=3    )    )

           for i in range(6    ):
                 _lowerCamelCase           =					cpu_disk_arr[i]
                 _lowerCamelCase           =					rect.copy().set_fill(A_					,					opacity=0.8    ).scale(2.0    )
                 cpa.generate_target()
                 cpa.target.move_to(model_base[i]    )

                 if i == 0:
                       rect.set_fill(A_					,					opacity=0.8    )
                       rect.generate_target()
                       rect.target.move_to(cpu_left_col_base[0]    ).scale(2.0    )

                       self.remove(
                           *A_					,					*A_					,					)

                 else:
                       rect.generate_target()
                       rect.target.move_to(cpu_left_col_base[i]    ).scale(2.0    )
                 self.play(MoveToTarget(A_    )					,					MoveToTarget(A_    )					,					model_base[i].animate.set_stroke(A_    )    )
           self.play(FadeOut(A_    )    )

           _lowerCamelCase           =					MarkupText(
               F'Finally, hooks are added to each weight in the model\nto transfer the weights from CPU to GPU\n\t\tand back when needed.'					,					font_size=24					,					)
           step_a.move_to([2, 2, 0]    )

           self.play(Write(A_					,					run_time=3    )    )

           _lowerCamelCase           =					[]
           _lowerCamelCase           =					[]
           for i in range(6    ):
                 _lowerCamelCase           =					Arrow(start=A_					,					end=A_					,					color=A_					,					buff=0.5    )
                 a.next_to(model_base[i].get_left()					,					A_					,					buff=0.2    )
                 arrows.append(A_    )
                 animations.append(Write(A_    )    )
           self.play(*A_    )
           self.wait()






'''simple docstring'''







from __future__ import annotations





def 							lowerCamelCase_   (	SCREAMING_SNAKE_CASE__   :      list[int | float] )			->						int | float:
						if len(SCREAMING_SNAKE_CASE__ ) == 0:
												raise ValueError('''find_min() arg is an empty sequence''' )
						UpperCAmelCase_      :   Optional[int]      =	nums[0]
						for num in nums:
												UpperCAmelCase_      :   Tuple      =	min(SCREAMING_SNAKE_CASE__,      SCREAMING_SNAKE_CASE__ )
						return min_num


if __name__ == "__main__":
					import doctest

					doctest.testmod(verbose=True)





