






from manim import *

class      UpperCamelCase_							(				UpperCamelCase       ):




						def      snake_case__(    self       )			->						Union[str, Any]:
													_a  :    Any			=						Rectangle(height=0.5		,	width=0.5       )
													_a  :    int			=						Rectangle(height=0.46		,	width=0.46       ).set_stroke(width=0       )
													_a  :    str			=						Rectangle(height=0.25		,	width=0.25       )

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

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

													_a  :    int			=						[mem.copy() for i in range(6       )]
													_a  :    List[str]			=						VGroup(*lowercase       ).arrange(lowercase		,	buff=0       )

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

													_a  :    Optional[int]			=						[]
													_a  :    List[Any]			=						[]

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

																				_a  :    Tuple			=						Rectangle(height=0.46 / 4		,	width=0.46 / 3       ).set_stroke(width=0.0       ).set_fill(lowercase		,	opacity=0.7       )

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

													self.add(*lowercase		,	*lowercase       )

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

													_a  :    str			=						[]

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

													self.add(*lowercase       )

													_a  :    Optional[int]			=						Square(side_length=2.2       )
													key.move_to([-5, 2, 0]       )

													_a  :    Dict			=						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(lowercase		,	lowercase       )

													_a  :    List[Any]			=						MarkupText(
													    F'<span fgcolor=\'{BLUE}\'>●</span> Checkpoint'		,	font_size=18		,	)

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

													_a  :    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(lowercase		,	run_time=3       )       )

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

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

																											self.remove(
																											    *lowercase		,	*lowercase		,	)

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

													_a  :    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(lowercase		,	run_time=3       )       )

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







from math import radians as angle_to_radians
from math import sin

# Acceleration Constant on Earth (unit m/s^2)
__lowerCamelCase						= 9.8_06_65






def    UpperCamelCase__  (   UpperCAmelCase    ,	UpperCAmelCase     )     ->		None:







							"""simple docstring"""





							if not isinstance(UpperCAmelCase    ,	(int, float)     ):
														raise TypeError('''Invalid velocity. Should be a positive number.'''     )

							if not isinstance(UpperCAmelCase    ,	(int, float)     ):
														raise TypeError('''Invalid angle. Range is 1-90 degrees.'''     )

							# Ensure valid angle
							if angle > 90 or angle < 1:
														raise ValueError('''Invalid angle. Range is 1-90 degrees.'''     )

							# Ensure valid velocity
							if init_velocity < 0:
														raise ValueError('''Invalid velocity. Should be a positive number.'''     )






def    UpperCamelCase__  (   UpperCAmelCase    ,	UpperCAmelCase     )     ->		float:







							"""simple docstring"""





							check_args(UpperCAmelCase    ,	UpperCAmelCase     )
							_a  :    Dict			=						angle_to_radians(2 * angle     )
							return round(init_velocity**2 * sin(UpperCAmelCase     ) / g    ,	2     )






def    UpperCamelCase__  (   UpperCAmelCase    ,	UpperCAmelCase     )     ->		float:







							"""simple docstring"""





							check_args(UpperCAmelCase    ,	UpperCAmelCase     )
							_a  :    Union[str, Any]			=						angle_to_radians(UpperCAmelCase     )
							return round(init_velocity**2 * sin(UpperCAmelCase     ) ** 2 / (2 * g)    ,	2     )






def    UpperCamelCase__  (   UpperCAmelCase    ,	UpperCAmelCase     )     ->		float:







							"""simple docstring"""





							check_args(UpperCAmelCase    ,	UpperCAmelCase     )
							_a  :    str			=						angle_to_radians(UpperCAmelCase     )
							return round(2 * init_velocity * sin(UpperCAmelCase     ) / g    ,	2     )






def    UpperCamelCase__  (   )     ->		None:







							"""simple docstring"""





							_a		,					_a  :    Any			=						25, 20
							assert horizontal_distance(UpperCAmelCase    ,	UpperCAmelCase     ) == 4_0.9_7
							assert max_height(UpperCAmelCase    ,	UpperCAmelCase     ) == 3.7_3
							assert total_time(UpperCAmelCase    ,	UpperCAmelCase     ) == 1.7_4


if __name__ == "__main__":
						from doctest import testmod

						testmod()

						# Get input from user
						__lowerCamelCase						= float(input('Initial Velocity: ').strip())

						# Get input from user
						__lowerCamelCase						= float(input('angle: ').strip())

						# Print results
						print()
						print('Results: ')
						print(F'''Horizontal Distance: {horizontal_distance(init_vel, angle)!s} [m]''')
						print(F'''Maximum Height: {max_height(init_vel, angle)!s} [m]''')
						print(F'''Total Time: {total_time(init_vel, angle)!s} [s]''')