




from manim import *

class      UpperCAmelCase						(			A   ):






   def  _a						(	self   :       Tuple     )->			str:
     _lowercase: Any						     =    Rectangle(height=0.5						,					width=0.5     )
     _lowercase: Optional[Any]						     =    Rectangle(height=0.46						,					width=0.46     ).set_stroke(width=0     )
     _lowercase: List[str]						     =    Rectangle(height=0.25						,					width=0.25     )

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

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

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

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

     _lowercase: List[Any]						     =    []
     _lowercase: Optional[Any]						     =    []

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

       _lowercase: Optional[Any]						     =    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_     )

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

     _lowercase: List[Any]						     =    []

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

     self.add(*UpperCamelCase_     )

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

     _lowercase: Optional[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(UpperCamelCase_						,					UpperCamelCase_     )

     _lowercase: Any						     =    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_     )

     _lowercase: Optional[int]						     =    MarkupText(f'The offloaded weights are all sent to the CPU.'						,					font_size=24     )
     step_a.move_to([2, 2, 0]     )

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

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

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

         self.remove(
             *UpperCamelCase_						,					*UpperCamelCase_						,					)

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

     _lowercase: List[str]						     =    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(UpperCamelCase_						,					run_time=3     )     )

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






from __future__ import annotations

from pathlib import Path


def 		_lowerCamelCase				(					UpperCamelCase					,     UpperCamelCase							)			->		int:





  """simple docstring"""





  return pointa[0] * pointa[1] - pointa[1] * pointa[0]


def 		_lowerCamelCase				(					UpperCamelCase					,     UpperCamelCase					,     UpperCamelCase					,     UpperCamelCase					,     UpperCamelCase					,     UpperCamelCase							)			->		bool:





  """simple docstring"""





  _lowercase: tuple[int, int]						     =    (xa, ya)
  _lowercase: tuple[int, int]						     =    (xa - xa, ya - ya)
  _lowercase: tuple[int, int]						     =    (xa - xa, ya - ya)
  _lowercase: float						     =    -vector_product(UpperCamelCase					,     UpperCamelCase							) / vector_product(
      UpperCamelCase					,     UpperCamelCase							)
  _lowercase: float						     =    +vector_product(UpperCamelCase					,     UpperCamelCase							) / vector_product(
      UpperCamelCase					,     UpperCamelCase							)

  return a > 0 and b > 0 and a + b < 1


def 		_lowerCamelCase				(					UpperCamelCase = "p102_triangles.txt"							)			->		int:





  """simple docstring"""





  _lowercase: str						     =    Path(UpperCamelCase							).parent.joinpath(UpperCamelCase							).read_text(encoding='utf-8'							)

  _lowercase: list[list[int]]						     =    []
  for line in data.strip().split('\n'							):
    triangles.append([int(UpperCamelCase							) for number in line.split(','							)]							)

  _lowercase: int						     =    0
  _lowercase: list[int]

  for triangle in triangles:
    ret += contains_origin(*UpperCamelCase							)

  return ret


if __name__ == "__main__":
   print(f'''{solution() = }''')
