


from manim import *

class    __magic_name__						(  __lowerCAmelCase):


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





      '''simple docstring'''






      UpperCamelCase__       :     List[Any] 							= Rectangle(height=0.5				,						width=0.5      )
      UpperCamelCase__       :     Dict 							= Rectangle(height=0.46				,						width=0.46      ).set_stroke(width=0      )
      UpperCamelCase__       :     Union[str, Any] 							= Rectangle(height=0.25				,						width=0.25      )

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

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

      UpperCamelCase__       :     Dict 							= [mem.copy() for i in range(6      )]
      UpperCamelCase__       :     str 							= VGroup(*lowerCamelCase__      ).arrange(lowerCamelCase__				,						buff=0      )

      UpperCamelCase__       :     Optional[int] 							= Text('''Model'''				,						font_size=24      )
      UpperCamelCase__       :     int 							= Group(lowerCamelCase__				,						lowerCamelCase__      ).arrange(lowerCamelCase__				,						buff=0.5				,						aligned_edge=lowerCamelCase__      )
      model.move_to([3, -1.0, 0]      )
      self.add(lowerCamelCase__      )

      UpperCamelCase__       :     Any 							= []
      UpperCamelCase__       :     Optional[int] 							= []

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

       UpperCamelCase__       :     Union[str, Any] 							= Rectangle(height=0.46 / 4				,						width=0.46 / 3      ).set_stroke(width=0.0      ).set_fill(lowerCamelCase__				,						opacity=0.7      )

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

      self.add(*lowerCamelCase__				,						*lowerCamelCase__      )

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

      UpperCamelCase__       :     Dict 							= []

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

      self.add(*lowerCamelCase__      )

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

      UpperCamelCase__       :     int 							= 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(lowerCamelCase__				,						lowerCamelCase__      )

      UpperCamelCase__       :     Optional[Any] 							= MarkupText(
          F"<span fgcolor='{BLUE}'>●</span> Checkpoint"				,						font_size=18				,						)

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

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

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

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

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

        self.remove(
            *lowerCamelCase__				,						*lowerCamelCase__				,						)

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

      UpperCamelCase__       :     Tuple 							= 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(lowerCamelCase__				,						run_time=3      )      )

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






import numpy as np

def       _a	(					SCREAMING_SNAKE_CASE						:					Tuple  ):







 """simple docstring"""



 UpperCamelCase__       :     str 							= np.exp(SCREAMING_SNAKE_CASE  )

 # Add up the all the exponentials
 UpperCamelCase__       :     Optional[int] 							= np.sum(SCREAMING_SNAKE_CASE  )

 # Divide every exponent by the sum of all exponents
 UpperCamelCase__       :     Optional[Any] 							= exponent_vector / sum_of_exponents

 return softmax_vector


if __name__ == "__main__":
       print(softmax((0,)))


