




from manim import *


class 							UpperCamelCase_       (					UpperCAmelCase__	):

    '''simple docstring'''






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





           '''simple docstring'''

           A__ 					=       Rectangle(height=0.5   ,					width=0.5)
           A__ 					=       Rectangle(height=0.25   ,					width=0.25)
           A__ 					=       Rectangle(height=0.46   ,					width=0.46).set_stroke(width=0)

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

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

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

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

           A__ 					=       []
           A__ 					=       []
           A__ 					=       []

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

                  A__ 					=       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__)

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

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

           self.add(UpperCAmelCase__)

           A__ 					=       []
           A__ 					=       []

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

                  A__ 					=       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__)

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

           A__ 					=       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__)

           A__ 					=       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__)

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

           A__ 					=       [meta_mem.copy() for i in range(6)]
           A__ 					=       [meta_mem.copy() for i in range(6)]
           A__ 					=       VGroup(*UpperCAmelCase__).arrange(UpperCAmelCase__   ,					buff=0)
           A__ 					=       VGroup(*UpperCAmelCase__).arrange(UpperCAmelCase__   ,					buff=0)
           A__ 					=       VGroup(UpperCAmelCase__   ,					UpperCAmelCase__).arrange(UpperCAmelCase__   ,					buff=0)
           A__ 					=       Text('''Disk'''   ,					font_size=24)
           A__ 					=       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))

           A__ 					=       []
           for i, rect in enumerate(UpperCAmelCase__):
                  A__ 					=       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__))

           A__ 					=       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 typing import Any

def lowercase    (  SCREAMING_SNAKE_CASE )			->							None:


			'''simple docstring'''







			create_state_space_tree(SCREAMING_SNAKE_CASE       ,    []       ,    0 )

def lowercase    (  SCREAMING_SNAKE_CASE       ,    SCREAMING_SNAKE_CASE       ,    SCREAMING_SNAKE_CASE )			->							None:


			'''simple docstring'''







			if index == len(SCREAMING_SNAKE_CASE ):
						print(SCREAMING_SNAKE_CASE )
						return

			create_state_space_tree(SCREAMING_SNAKE_CASE       ,    SCREAMING_SNAKE_CASE       ,    index + 1 )
			current_subsequence.append(sequence[index] )
			create_state_space_tree(SCREAMING_SNAKE_CASE       ,    SCREAMING_SNAKE_CASE       ,    index + 1 )
			current_subsequence.pop()


if __name__ == "__main__":
				SCREAMING_SNAKE_CASE__     :     list[Any]		    =       [3, 1, 2, 4]
				generate_all_subsequences(seq)

				seq.clear()
				seq.extend(["A", "B", "C"])
				generate_all_subsequences(seq)
