





from manim import *


class 					__magic_name__  (							lowerCamelCase__							):





     """simple docstring"""



     def 						SCREAMING_SNAKE_CASE		(							self       :int  ):





        '''simple docstring'''




        A_					:				List[str]          =			Rectangle(height=0.5			,      width=0.5  )
        A_					:				str          =			Rectangle(height=0.46			,      width=0.46  ).set_stroke(width=0  )
        A_					:				str          =			Rectangle(height=0.25			,      width=0.25  )

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

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

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

        A_					:				Optional[Any]          =			Text("Model"			,      font_size=24  )
        A_					:				Union[str, Any]          =			Group(snake_case			,      snake_case  ).arrange(snake_case			,      buff=0.5			,      aligned_edge=snake_case  )
        model.move_to([3, -1.0, 0]  )
        self.add(snake_case  )

        A_					:				int          =			[]
        A_					:				Tuple          =			[]

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

           A_					:				Optional[int]          =			Rectangle(height=0.46 / 4			,      width=0.46 / 3  ).set_stroke(width=0.0  ).set_fill(snake_case			,      opacity=0.7  )

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

        self.add(*snake_case			,      *snake_case  )

        A_					:				List[str]          =			[meta_mem.copy() for i in range(6  )]
        A_					:				Any          =			[meta_mem.copy() for i in range(6  )]
        A_					:				Optional[int]          =			VGroup(*snake_case  ).arrange(snake_case			,      buff=0  )
        A_					:				Dict          =			VGroup(*snake_case  ).arrange(snake_case			,      buff=0  )
        A_					:				Tuple          =			VGroup(snake_case			,      snake_case  ).arrange(snake_case			,      buff=0  )
        A_					:				Dict          =			Text("Disk"			,      font_size=24  )
        A_					:				int          =			Group(snake_case			,      snake_case  ).arrange(snake_case			,      buff=0.5			,      aligned_edge=snake_case  )
        disk.move_to([-4.0, -1.25, 0]  )
        self.add(snake_case			,      snake_case  )

        A_					:				List[Any]          =			[]

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

        self.add(*snake_case  )

        A_					:				int          =			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=18			,      )

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

        self.add(snake_case			,      snake_case  )

        A_					:				int          =			MarkupText(
            f"<span fgcolor='{BLUE}'>●</span> Checkpoint"			,      font_size=18			,      )

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

        A_					:				List[str]          =			MarkupText(f"The offloaded weights are all sent to the CPU."			,      font_size=24  )
        step_a.move_to([2, 2, 0]  )

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

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

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

              self.remove(
                  *snake_case			,      *snake_case			,      )

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

        A_					:				int          =			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(snake_case			,      run_time=3  )  )

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







from __future__ import annotations

def      __snake_case						(					_lowerCAmelCase : int	) ->						list[int]:
   assert (
       isinstance(_lowerCAmelCase				,				_lowerCAmelCase	) and mask > 0
   ), f"mask needs to be positive integer, your input {mask}"
   A_					:				Optional[Any]          =			[]
   A_					:				Optional[int]          =			mask

   while submask:
      all_submasks.append(_lowerCAmelCase	)
      A_					:				List[str]          =			(submask - 1) & mask

   return all_submasks


if __name__ == "__main__":
 import doctest

 doctest.testmod()
