





from manim import *






class 					__A    (    A__ ):

			'''simple docstring'''







			def 		__lowerCamelCase				(    self							):



				'''simple docstring'''







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

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

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

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

				lowerCamelCase__								=		Text('''Model'''       ,  font_size=2_4							)
				lowerCamelCase__								=		Group(__snake_case       ,  __snake_case							).arrange(__snake_case       ,  buff=0.5       ,  aligned_edge=__snake_case							)
				model.move_to([3, -1.0, 0]							)
				self.add(__snake_case							)

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

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

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

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

				lowerCamelCase__								=		Text('''Loaded Checkpoint'''       ,  font_size=2_4							)
				lowerCamelCase__								=		Group(__snake_case       ,  __snake_case							).arrange(__snake_case       ,  aligned_edge=__snake_case       ,  buff=0.4							)
				checkpoint.move_to([3, 0.5, 0]							)

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

				lowerCamelCase__								=		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(__snake_case       ,  __snake_case							)

				lowerCamelCase__								=		MarkupText(
				    F'<span fgcolor=\'{BLUE}\'>●</span> Checkpoint'       ,  font_size=1_8       ,  )

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

				lowerCamelCase__								=		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=2_4       ,  )
				step_a.move_to([2, 2, 0]							)
				self.play(Write(__snake_case							)       ,  Write(__snake_case							)							)

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

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

					lowerCamelCase__								=		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(__snake_case       ,  run_time=1.5							)							)

				self.play(*__snake_case							)
				self.play(*__snake_case							)
				self.wait()








'''simple docstring'''






from __future__ import annotations


def  snake_case_     (					_lowerCAmelCase  :						str   ,      _lowerCAmelCase  :						str  )      ->   bool:
							UpperCAmelCase :       str 							=		get_failure_array(_lowerCAmelCase  )

							# 2) Step through text searching for pattern
							UpperCAmelCase							,		UpperCAmelCase :       Optional[Any] 							=		0, 0  # index into text, pattern
							while i < len(_lowerCAmelCase  ):
														if pattern[j] == text[i]:
																					if j == (len(_lowerCAmelCase  ) - 1):
																												return True
																					j += 1

														# if this is a prefix in our pattern
														# just go back far enough to continue
														elif j > 0:
																					UpperCAmelCase :       Optional[Any] 							=		failure[j - 1]
																					continue
														i += 1
							return False


def  snake_case_     (					_lowerCAmelCase  :						str  )      ->   list[int]:
							UpperCAmelCase :       Optional[Any] 							=		[0]
							UpperCAmelCase :       str 							=		0
							UpperCAmelCase :       List[str] 							=		1
							while j < len(_lowerCAmelCase  ):
														if pattern[i] == pattern[j]:
																					i += 1
														elif i > 0:
																					UpperCAmelCase :       Union[str, Any] 							=		failure[i - 1]
																					continue
														j += 1
														failure.append(_lowerCAmelCase  )
							return failure


if __name__ == "__main__":
						# Test 1)
						UpperCamelCase__:   str								=			"abc1abc12"
						UpperCamelCase__:   str								=			"alskfjaldsabc1abc1abc12k23adsfabcabc"
						UpperCamelCase__:   Any								=			"alskfjaldsk23adsfabcabc"
						assert kmp(pattern, texta) and not kmp(pattern, texta)

						# Test 2)
						UpperCamelCase__:   Tuple								=			"ABABX"
						UpperCamelCase__:   Union[str, Any]								=			"ABABZABABYABABX"
						assert kmp(pattern, text)

						# Test 3)
						UpperCamelCase__:   Any								=			"AAAB"
						UpperCamelCase__:   str								=			"ABAAAAAB"
						assert kmp(pattern, text)

						# Test 4)
						UpperCamelCase__:   int								=			"abcdabcy"
						UpperCamelCase__:   Any								=			"abcxabcdabxabcdabcdabcy"
						assert kmp(pattern, text)

						# Test 5)
						UpperCamelCase__:   List[str]								=			"aabaabaaa"
						assert get_failure_array(pattern) == [0, 1, 0, 1, 2, 3, 4, 5, 2]





