
from manim import *




class  lowerCamelCase__							(				__lowercase):




	'''simple docstring'''




	def    _lowerCamelCase				(					self		:Dict						)		-> List[Any]:
								__UpperCamelCase	:   Dict			   =					Rectangle(height=0.5     ,   width=0.5						)
								__UpperCamelCase	:   Union[str, Any]			   =					Rectangle(height=0.46     ,   width=0.46						).set_stroke(width=0						)

								__UpperCamelCase	:   List[Any]			   =					Rectangle(height=0.25     ,   width=0.25						)

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

								__UpperCamelCase	:   List[Any]			   =					[mem.copy() for i in range(4						)]
								__UpperCamelCase	:   Dict			   =					VGroup(*a						).arrange(a     ,   buff=0						)
								__UpperCamelCase	:   List[str]			   =					Text("GPU"     ,   font_size=2_4						)
								__UpperCamelCase	:   List[Any]			   =					Group(a     ,   a						).arrange(a     ,   buff=0.5     ,   aligned_edge=a						)
								gpu.move_to([-1, -1, 0]						)
								self.add(a						)

								__UpperCamelCase	:   List[Any]			   =					[mem.copy() for i in range(6						)]
								__UpperCamelCase	:   Any			   =					VGroup(*a						).arrange(a     ,   buff=0						)

								__UpperCamelCase	:   Any			   =					Text("Model"     ,   font_size=2_4						)
								__UpperCamelCase	:   Tuple			   =					Group(a     ,   a						).arrange(a     ,   buff=0.5     ,   aligned_edge=a						)
								model.move_to([3, -1.0, 0]						)
								self.add(a						)

								__UpperCamelCase	:   Dict			   =					[]
								__UpperCamelCase	:   Dict			   =					[]

								for i, rect in enumerate(a						):
															__UpperCamelCase	:   List[str]			   =					fill.copy().set_fill(a     ,   opacity=0.8						)
															target.move_to(a						)
															model_arr.append(a						)

															__UpperCamelCase	:   Any			   =					Rectangle(height=0.46     ,   width=0.46						).set_stroke(width=0.0						).set_fill(a     ,   opacity=0.8						)
															cpu_target.move_to(cpu_left_col_base[i]						)
															model_cpu_arr.append(a						)

								self.add(*a     ,   *a						)

								__UpperCamelCase	:   int			   =					[meta_mem.copy() for i in range(6						)]
								__UpperCamelCase	:   Union[str, Any]			   =					[meta_mem.copy() for i in range(6						)]
								__UpperCamelCase	:   str			   =					VGroup(*a						).arrange(a     ,   buff=0						)
								__UpperCamelCase	:   str			   =					VGroup(*a						).arrange(a     ,   buff=0						)
								__UpperCamelCase	:   Any			   =					VGroup(a     ,   a						).arrange(a     ,   buff=0						)
								__UpperCamelCase	:   Tuple			   =					Text("Disk"     ,   font_size=2_4						)
								__UpperCamelCase	:   Optional[Any]			   =					Group(a     ,   a						).arrange(a     ,   buff=0.5     ,   aligned_edge=a						)
								disk.move_to([-4, -1.25, 0]						)
								self.add(a     ,   a						)

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

								__UpperCamelCase	:   Any			   =					MarkupText(
								    f'<b>Key:</b>\n\n<span fgcolor=\'{YELLOW}\'>●</span> Empty Model'     ,   font_size=1_8     ,   )

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

								self.add(a     ,   a						)

								__UpperCamelCase	:   Any			   =					MarkupText(
								    f'<span fgcolor=\'{BLUE}\'>●</span> Checkpoint'     ,   font_size=1_8     ,   )

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

								__UpperCamelCase	:   Tuple			   =					MarkupText(
								    f'Now watch as an input is passed through the model\nand how the memory is utilized and handled.'     ,   font_size=2_4     ,   )
								step_a.move_to([2, 2, 0]						)

								self.play(Write(a						)						)

								__UpperCamelCase	:   Optional[Any]			   =					Square(0.3						)
								input.set_fill(a     ,   opacity=1.0						)
								input.set_stroke(width=0.0						)
								input.next_to(model_base[0]     ,   a     ,   buff=0.5						)

								self.play(Write(a						)						)

								input.generate_target()
								input.target.next_to(model_arr[0]     ,   direction=a     ,   buff=0.02						)
								self.play(MoveToTarget(a						)						)

								self.play(FadeOut(a						)						)

								__UpperCamelCase	:   Optional[int]			   =					Arrow(start=a     ,   end=a     ,   color=a     ,   buff=0.5						)
								a.next_to(model_arr[0].get_left()     ,   a     ,   buff=0.2						)

								model_cpu_arr[0].generate_target()
								model_cpu_arr[0].target.move_to(gpu_rect[0]						)

								__UpperCamelCase	:   Dict			   =					MarkupText(
								    f'As the input reaches a layer, the hook triggers\nand weights are moved from the CPU\nto the GPU and back.'     ,   font_size=2_4     ,   )
								step_a.move_to([2, 2, 0]						)

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

								__UpperCamelCase	:   Optional[Any]			   =					{"run_time": 1, "fade_in": True, "fade_out": True, "buff": 0.02}

								self.play(
								    Write(a						)     ,   Circumscribe(model_arr[0]     ,   color=a     ,   **a						)     ,   Circumscribe(model_cpu_arr[0]     ,   color=a     ,   **a						)     ,   Circumscribe(gpu_rect[0]     ,   color=a     ,   **a						)     ,   )
								self.play(MoveToTarget(model_cpu_arr[0]						)						)

								__UpperCamelCase	:   Optional[Any]			   =					a.copy()
								for i in range(6						):
															a_c.next_to(model_arr[i].get_right() + 0.02     ,   a     ,   buff=0.2						)

															input.generate_target()
															input.target.move_to(model_arr[i].get_right() + 0.02						)

															__UpperCamelCase	:   Dict			   =					AnimationGroup(
															    FadeOut(a     ,   run_time=0.5						)     ,   MoveToTarget(a     ,   run_time=0.5						)     ,   FadeIn(a     ,   run_time=0.5						)     ,   lag_ratio=0.2						)

															self.play(a						)

															model_cpu_arr[i].generate_target()
															model_cpu_arr[i].target.move_to(cpu_left_col_base[i]						)

															if i < 5:
																						model_cpu_arr[i + 1].generate_target()
																						model_cpu_arr[i + 1].target.move_to(gpu_rect[0]						)
																						if i >= 1:
																													__UpperCamelCase	:   List[str]			   =					0.7

																						self.play(
																						    Circumscribe(model_arr[i]     ,   **a						)     ,   Circumscribe(cpu_left_col_base[i]     ,   **a						)     ,   Circumscribe(cpu_left_col_base[i + 1]     ,   color=a     ,   **a						)     ,   Circumscribe(gpu_rect[0]     ,   color=a     ,   **a						)     ,   Circumscribe(model_arr[i + 1]     ,   color=a     ,   **a						)     ,   )
																						if i < 1:
																													self.play(
																													    MoveToTarget(model_cpu_arr[i]						)     ,   MoveToTarget(model_cpu_arr[i + 1]						)     ,   )
																						else:
																													self.play(
																													    MoveToTarget(model_cpu_arr[i]     ,   run_time=0.7						)     ,   MoveToTarget(model_cpu_arr[i + 1]     ,   run_time=0.7						)     ,   )
															else:
																						model_cpu_arr[i].generate_target()
																						model_cpu_arr[i].target.move_to(cpu_left_col_base[-1]						)
																						input.generate_target()
																						input.target.next_to(model_arr[-1].get_right()     ,   RIGHT + 0.02     ,   buff=0.2						)

																						self.play(
																						    Circumscribe(model_arr[-1]     ,   color=a     ,   **a						)     ,   Circumscribe(cpu_left_col_base[-1]     ,   color=a     ,   **a						)     ,   Circumscribe(gpu_rect[0]     ,   color=a     ,   **a						)     ,   )

																						self.play(MoveToTarget(model_cpu_arr[i]						)						)

															__UpperCamelCase	:   str			   =					a_c
															__UpperCamelCase	:   List[str]			   =					a_c.copy()

								input.generate_target()
								input.target.next_to(model_base[-1]     ,   RIGHT + 0.02     ,   buff=0.5						)
								self.play(
								    FadeOut(a						)     ,   FadeOut(a     ,   run_time=0.5						)     ,   )

								__UpperCamelCase	:   str			   =					MarkupText(f'Inference on a model too large for GPU memory\nis successfully completed.'     ,   font_size=2_4						)
								step_a.move_to([2, 2, 0]						)

								self.play(Write(a     ,   run_time=3						)     ,   MoveToTarget(a						)						)

								self.wait()

def 	_SCREAMING_SNAKE_CASE					(		_lowerCamelCase :			int						,  _lowerCamelCase :			int)					->    float:






							'''simple docstring'''





							return base * power(_lowerCamelCase						,  (exponent - 1)) if exponent else 1


if __name__ == "__main__":
		print('Raise base to the power of exponent using recursion...')
		lowercase  :					Optional[int]													=       int(input('Enter the base: ').strip())
		lowercase  :					Tuple													=       int(input('Enter the exponent: ').strip())
		lowercase  :					str													=       power(base, abs(exponent))
		if exponent < 0:  # power() does not properly deal w/ negative exponents
				lowercase  :					Tuple													=       1 / result
		print(f"{base} to the power of {exponent} is {result}")