


from manim import *







class 				snake_case__(							UpperCAmelCase__							):







						'''simple docstring'''




						def 						lowercase_ (				self							)					->    Optional[int]:
										lowerCAmelCase_ :      Union[str, Any]    				=				Rectangle(height=0.5   ,						width=0.5							)
										lowerCAmelCase_ :      Optional[Any]    				=				Rectangle(height=0.46   ,						width=0.46							).set_stroke(width=0							)

										lowerCAmelCase_ :      Optional[int]    				=				Rectangle(height=0.25   ,						width=0.25							)

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

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

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

										lowerCAmelCase_ :      Optional[Any]    				=				Text('''Model'''   ,						font_size=2_4							)
										lowerCAmelCase_ :      Any    				=				Group(__lowercase   ,						__lowercase							).arrange(__lowercase   ,						buff=0.5   ,						aligned_edge=__lowercase							)
										model.move_to([3, -1.0, 0]							)
										self.add(__lowercase							)

										lowerCAmelCase_ :      List[Any]    				=				[]
										lowerCAmelCase_ :      str    				=				[]

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

														lowerCAmelCase_ :      int    				=				Rectangle(height=0.46   ,						width=0.46							).set_stroke(width=0.0							).set_fill(__lowercase   ,						opacity=0.8							)
														cpu_target.move_to(cpu_left_col_base[i]							)
														model_cpu_arr.append(__lowercase							)

										self.add(*__lowercase   ,						*__lowercase							)

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

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

										lowerCAmelCase_ :      Tuple    				=				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(__lowercase   ,						__lowercase							)

										lowerCAmelCase_ :      int    				=				MarkupText(
										    f"""<span fgcolor='{BLUE}'>●</span> Checkpoint"""   ,						font_size=1_8   ,						)

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

										lowerCAmelCase_ :      Optional[Any]    				=				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(__lowercase							)							)

										lowerCAmelCase_ :      Dict    				=				Square(0.3							)
										input.set_fill(__lowercase   ,						opacity=1.0							)
										input.set_stroke(width=0.0							)
										input.next_to(model_base[0]   ,						__lowercase   ,						buff=0.5							)

										self.play(Write(__lowercase							)							)

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

										self.play(FadeOut(__lowercase							)							)

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

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

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

										lowerCAmelCase_ :      Union[str, Any]    				=				{'''run_time''': 1, '''fade_in''': True, '''fade_out''': True, '''buff''': 0.02}

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

										lowerCAmelCase_ :      str    				=				a.copy()
										for i in range(6							):
														a_c.next_to(model_arr[i].get_right() + 0.02   ,						__lowercase   ,						buff=0.2							)

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

														lowerCAmelCase_ :      Tuple    				=				AnimationGroup(
														    FadeOut(__lowercase   ,						run_time=0.5							)   ,						MoveToTarget(__lowercase   ,						run_time=0.5							)   ,						FadeIn(__lowercase   ,						run_time=0.5							)   ,						lag_ratio=0.2							)

														self.play(__lowercase							)

														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:
																						lowerCAmelCase_ :      Dict    				=				0.7

																		self.play(
																		    Circumscribe(model_arr[i]   ,						**__lowercase							)   ,						Circumscribe(cpu_left_col_base[i]   ,						**__lowercase							)   ,						Circumscribe(cpu_left_col_base[i + 1]   ,						color=__lowercase   ,						**__lowercase							)   ,						Circumscribe(gpu_rect[0]   ,						color=__lowercase   ,						**__lowercase							)   ,						Circumscribe(model_arr[i + 1]   ,						color=__lowercase   ,						**__lowercase							)   ,						)
																		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=__lowercase   ,						**__lowercase							)   ,						Circumscribe(cpu_left_col_base[-1]   ,						color=__lowercase   ,						**__lowercase							)   ,						Circumscribe(gpu_rect[0]   ,						color=__lowercase   ,						**__lowercase							)   ,						)

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

														lowerCAmelCase_ :      Dict    				=				a_c
														lowerCAmelCase_ :      int    				=				a_c.copy()

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

										lowerCAmelCase_ :      Union[str, Any]    				=				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(__lowercase   ,						run_time=3							)   ,						MoveToTarget(__lowercase							)							)

										self.wait()



import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import Audio, Features, Value
from .base import TaskTemplate







@dataclass(frozen=UpperCAmelCase__							)
class 				snake_case__(							UpperCAmelCase__							):







						'''simple docstring'''




						SCREAMING_SNAKE_CASE__      :  str					=							field(default="""automatic-speech-recognition""",						metadata={"""include_in_asdict_even_if_is_default""": True}							)
						SCREAMING_SNAKE_CASE__      :  ClassVar[Features]					=							Features({"""audio""": Audio()}							)
						SCREAMING_SNAKE_CASE__      :  ClassVar[Features]					=							Features({"""transcription""": Value("""string"""							)}							)
						SCREAMING_SNAKE_CASE__      :  str					=							"audio"
						SCREAMING_SNAKE_CASE__      :  str					=							"transcription"




						def 						lowercase_ (				self   ,						__lowercase							)					->    int:
										if self.audio_column not in features:
														raise ValueError(f"""Column {self.audio_column} is not present in features."""							)
										if not isinstance(features[self.audio_column]   ,						__lowercase							):
														raise ValueError(f"""Column {self.audio_column} is not an Audio type."""							)
										lowerCAmelCase_ :      List[str]    				=				copy.deepcopy(self							)
										lowerCAmelCase_ :      Optional[Any]    				=				self.input_schema.copy()
										lowerCAmelCase_ :      Optional[Any]    				=				features[self.audio_column]
										lowerCAmelCase_ :      List[str]    				=				input_schema
										return task_template




						@property
						def 						lowercase_ (				self							)					->    Dict[str, str]:
										return {self.audio_column: "audio", self.transcription_column: "transcription"}