
'''simple docstring'''
from manim import *


class 			SCREAMING_SNAKE_CASE__      (     snake_case_):







				def 						UpperCAmelCase_    (       self     )->		str:







											'''simple docstring'''






											UpperCamelCase   			=     Rectangle(height=0.5						,				width=0.5     )
											UpperCamelCase   			=     Rectangle(height=0.46						,				width=0.46     ).set_stroke(width=0     )

											UpperCamelCase   			=     [mem.copy() for i in range(6     )]
											UpperCamelCase   			=     [mem.copy() for i in range(6     )]
											UpperCamelCase   			=     VGroup(*A_     ).arrange(A_						,				buff=0     )
											UpperCamelCase   			=     VGroup(*A_     ).arrange(A_						,				buff=0     )
											UpperCamelCase   			=     VGroup(A_						,				A_     ).arrange(A_						,				buff=0     )
											UpperCamelCase   			=     Text('CPU'						,				font_size=24     )
											UpperCamelCase   			=     Group(A_						,				A_     ).arrange(A_						,				buff=0.5						,				aligned_edge=A_     )
											cpu.move_to([-2.5, -0.5, 0]     )
											self.add(A_     )

											UpperCamelCase   			=     [mem.copy() for i in range(4     )]
											UpperCamelCase   			=     VGroup(*A_     ).arrange(A_						,				buff=0     )
											UpperCamelCase   			=     Text('GPU'						,				font_size=24     )
											UpperCamelCase   			=     Group(A_						,				A_     ).arrange(A_						,				buff=0.5						,				aligned_edge=A_     )
											gpu.move_to([-1, -1, 0]     )
											self.add(A_     )

											UpperCamelCase   			=     [mem.copy() for i in range(6     )]
											UpperCamelCase   			=     VGroup(*A_     ).arrange(A_						,				buff=0     )

											UpperCamelCase   			=     Text('Model'						,				font_size=24     )
											UpperCamelCase   			=     Group(A_						,				A_     ).arrange(A_						,				buff=0.5						,				aligned_edge=A_     )
											model.move_to([3, -1.0, 0]     )
											self.add(A_     )

											UpperCamelCase   			=     []
											for i, rect in enumerate(A_     ):
																		rect.set_stroke(A_     )
																		# target = fill.copy().set_fill(YELLOW, opacity=0.7)
																		# target.move_to(rect)
																		# self.add(target)

																		UpperCamelCase   			=     Rectangle(height=0.46 / 4						,				width=0.46 / 3     ).set_stroke(width=0.0     ).set_fill(A_						,				opacity=0.7     )

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

											UpperCamelCase   			=     [mem.copy() for i in range(6     )]
											UpperCamelCase   			=     VGroup(*A_     ).arrange(A_						,				buff=0     )

											UpperCamelCase   			=     Text('Loaded Checkpoint'						,				font_size=24     )
											UpperCamelCase   			=     Group(A_						,				A_     ).arrange(A_						,				aligned_edge=A_						,				buff=0.4     )
											checkpoint.move_to([3, 0.5, 0]     )

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

											UpperCamelCase   			=     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(A_						,				A_     )

											UpperCamelCase   			=     MarkupText(
											    F'''<span fgcolor=\'{BLUE}\'>●</span> Checkpoint'''						,				font_size=18						,				)

											blue_text.next_to(A_						,				DOWN * 2.4						,				aligned_edge=key_text.get_left()     )

											UpperCamelCase   			=     MarkupText(
											    F'''Next, a <i><span fgcolor="{BLUE}">second</span></i> model is loaded into memory,\nwith the weights of a <span fgcolor="{BLUE}">single shard</span>.'''						,				font_size=24						,				)
											step_a.move_to([2, 2, 0]     )
											self.play(Write(A_     )						,				Write(A_     )     )

											self.play(Write(A_						,				run_time=1     )						,				Create(A_						,				run_time=1     )     )

											UpperCamelCase   			=     []
											UpperCamelCase   			=     []
											for i, rect in enumerate(A_     ):
																		UpperCamelCase   			=     fill.copy().set_fill(A_						,				opacity=0.7     )
																		target.move_to(A_     )
																		first_animations.append(GrowFromCenter(A_						,				run_time=1     )     )

																		UpperCamelCase   			=     target.copy()
																		cpu_target.generate_target()
																		if i < 5:
																									cpu_target.target.move_to(cpu_left_col_base[i + 1]     )
																		else:
																									cpu_target.target.move_to(cpu_right_col_base[i - 5]     )
																		second_animations.append(MoveToTarget(A_						,				run_time=1.5     )     )

											self.play(*A_     )
											self.play(*A_     )
											self.wait()






'''simple docstring'''
from __future__ import annotations

lowerCAmelCase					:    Union[str, Any]           = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0]
lowerCAmelCase					:    List[str]           = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1]







def 		A_(     A						:		list[float]):
							UpperCamelCase   			=     []
							UpperCamelCase   			=     len(A)

							for i in range(A):
														UpperCamelCase   			=     -1
														for j in range(i + 1		,     A):
																					if arr[i] < arr[j]:
																												UpperCamelCase   			=     arr[j]
																												break
														result.append(A)
							return result







def 		A_(     A						:		list[float]):
							UpperCamelCase   			=     []
							for i, outer in enumerate(A):
														UpperCamelCase   			=     -1
														for inner in arr[i + 1 :]:
																					if outer < inner:
																												UpperCamelCase   			=     inner
																												break
														result.append(A)
							return result







def 		A_(     A						:		list[float]):
							UpperCamelCase   			=     len(A)
							UpperCamelCase   			=     []
							UpperCamelCase   			=     [-1] * arr_size

							for index in reversed(range(A)):
														if stack:
																					while stack[-1] <= arr[index]:
																												stack.pop()
																												if not stack:
																																			break
														if stack:
																					UpperCamelCase   			=     stack[-1]
														stack.append(arr[index])
							return result


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

						testmod()
						print(next_greatest_element_slow(arr))
						print(next_greatest_element_fast(arr))
						print(next_greatest_element(arr))

						lowerCAmelCase					:    Optional[Any]           = (
						    'from __main__ import arr, next_greatest_element_slow, '
						    'next_greatest_element_fast, next_greatest_element'
						)
						print(
						    'next_greatest_element_slow():',
						    timeit('next_greatest_element_slow(arr)', setup=setup),
						)
						print(
						    'next_greatest_element_fast():',
						    timeit('next_greatest_element_fast(arr)', setup=setup),
						)
						print(
						    '     next_greatest_element():',
						    timeit('next_greatest_element(arr)', setup=setup),
						)




