





from manim import *

class       __A     (						a    ):


				def _snake_case       (		self							):
								lowerCamelCase	 =Rectangle(height=0.5   , width=0.5							)
								lowerCamelCase	 =Rectangle(height=0.2_5   , width=0.2_5							)
								lowerCamelCase	 =Rectangle(height=0.4_6   , width=0.4_6							).set_stroke(width=0							)

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

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

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

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

								lowerCamelCase	 =[]
								lowerCamelCase	 =[]
								lowerCamelCase	 =[]

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

												lowerCamelCase	 =Rectangle(height=0.4_6 / 4   , width=0.4_6 / 3							).set_stroke(width=0.0							).set_fill(UpperCAmelCase_   , opacity=0.7							)

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

								self.add(*UpperCAmelCase_   , *UpperCAmelCase_   , *UpperCAmelCase_							)

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

								lowerCamelCase	 =Text("""Loaded Checkpoint"""   , font_size=24							)
								lowerCamelCase	 =Group(UpperCAmelCase_   , UpperCAmelCase_							).arrange(UpperCAmelCase_   , buff=0.5   , aligned_edge=UpperCAmelCase_							)
								checkpoint.move_to([3, 0.5, 0]							)

								self.add(UpperCAmelCase_							)

								lowerCamelCase	 =[]
								lowerCamelCase	 =[]

								for i, rect in enumerate(UpperCAmelCase_							):
												lowerCamelCase	 =fill.copy().set_fill(UpperCAmelCase_   , opacity=0.7							)
												target.move_to(UpperCAmelCase_							)
												ckpt_arr.append(UpperCAmelCase_							)

												lowerCamelCase	 =target.copy()
												if i < 5:
																cpu_target.move_to(cpu_left_col_base[i + 1]							)
												else:
																cpu_target.move_to(cpu_right_col_base[i - 5]							)
												ckpt_cpu_arr.append(UpperCAmelCase_							)
								self.add(*UpperCAmelCase_   , *UpperCAmelCase_							)

								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=18   , )

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

								self.add(UpperCAmelCase_   , UpperCAmelCase_							)

								lowerCamelCase	 =MarkupText(
								    f"""<span fgcolor='{BLUE}'>●</span> Checkpoint"""   , font_size=18   , )

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

								lowerCamelCase	 =MarkupText(
								    f"""Based on the passed in configuration, weights are stored in\na variety of np.memmaps on disk or to a particular device."""   , font_size=24   , )
								step_a.move_to([2, 2, 0]							)

								lowerCamelCase	 =[meta_mem.copy() for i in range(6							)]
								lowerCamelCase	 =[meta_mem.copy() for i in range(6							)]
								lowerCamelCase	 =VGroup(*UpperCAmelCase_							).arrange(UpperCAmelCase_   , buff=0							)
								lowerCamelCase	 =VGroup(*UpperCAmelCase_							).arrange(UpperCAmelCase_   , buff=0							)
								lowerCamelCase	 =VGroup(UpperCAmelCase_   , UpperCAmelCase_							).arrange(UpperCAmelCase_   , buff=0							)
								lowerCamelCase	 =Text("""Disk"""   , font_size=24							)
								lowerCamelCase	 =Group(UpperCAmelCase_   , UpperCAmelCase_							).arrange(UpperCAmelCase_   , buff=0.5   , aligned_edge=UpperCAmelCase_							)
								disk.move_to([-4.0, -1.2_5, 0]							)
								self.play(Write(UpperCAmelCase_   , run_time=3							)   , Write(UpperCAmelCase_   , run_time=1							)   , Create(UpperCAmelCase_   , run_time=1							)							)

								lowerCamelCase	 =[]
								for i, rect in enumerate(UpperCAmelCase_							):
												lowerCamelCase	 =rect.copy()
												target.generate_target()
												target.target.move_to(disk_left_col_base[i]							).scale(0.5							)
												animations.append(MoveToTarget(UpperCAmelCase_   , run_time=1.5							)							)
								self.play(*UpperCAmelCase_							)

								self.play(FadeOut(UpperCAmelCase_							)							)

								lowerCamelCase	 =MarkupText(f"""Then, the checkpoint is removed from memory\nthrough garbage collection."""   , font_size=24							)
								step_a.move_to([2, 2, 0]							)

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

								self.play(
								    FadeOut(UpperCAmelCase_   , UpperCAmelCase_   , *UpperCAmelCase_   , *UpperCAmelCase_							)   , )

								self.wait()












from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCAmelCase__						:			str									={'''configuration_fnet''': ['''FNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FNetConfig''']}

try:
							if not is_sentencepiece_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCAmelCase__						:			List[Any]									=['''FNetTokenizer''']

try:
							if not is_tokenizers_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCAmelCase__						:			Any									=['''FNetTokenizerFast''']

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCAmelCase__						:			Dict									=[
							    '''FNET_PRETRAINED_MODEL_ARCHIVE_LIST''',
							    '''FNetForMaskedLM''',
							    '''FNetForMultipleChoice''',
							    '''FNetForNextSentencePrediction''',
							    '''FNetForPreTraining''',
							    '''FNetForQuestionAnswering''',
							    '''FNetForSequenceClassification''',
							    '''FNetForTokenClassification''',
							    '''FNetLayer''',
							    '''FNetModel''',
							    '''FNetPreTrainedModel''',
							]


if TYPE_CHECKING:
							from .configuration_fnet import FNET_PRETRAINED_CONFIG_ARCHIVE_MAP, FNetConfig

							try:
														if not is_sentencepiece_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tokenization_fnet import FNetTokenizer

							try:
														if not is_tokenizers_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tokenization_fnet_fast import FNetTokenizerFast

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_fnet import (
														    FNET_PRETRAINED_MODEL_ARCHIVE_LIST,
														    FNetForMaskedLM,
														    FNetForMultipleChoice,
														    FNetForNextSentencePrediction,
														    FNetForPreTraining,
														    FNetForQuestionAnswering,
														    FNetForSequenceClassification,
														    FNetForTokenClassification,
														    FNetLayer,
														    FNetModel,
														    FNetPreTrainedModel,
														)


else:
							import sys

							UpperCAmelCase__						:			Optional[int]									=_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





