




from manim import *

class       A   (		_a   ):







							def        __lowerCAmelCase      (  self	:  Dict )      ->							Dict:


														"""simple docstring"""


														_a     					=    Rectangle(height=0.5							,      width=0.5 )
														_a     					=    Rectangle(height=0.2_5							,      width=0.2_5 )
														_a     					=    Rectangle(height=0.4_6							,      width=0.4_6 ).set_stroke(width=0 )

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

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

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

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

														_a     					=    []
														_a     					=    []
														_a     					=    []

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

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

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

														self.add(*lowerCAmelCase__							,      *lowerCAmelCase__							,      *lowerCAmelCase__ )

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

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

														self.add(lowerCAmelCase__ )

														_a     					=    []
														_a     					=    []

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

																					_a     					=    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(lowerCAmelCase__ )
														self.add(*lowerCAmelCase__							,      *lowerCAmelCase__ )

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

														_a     					=    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(lowerCAmelCase__							,      lowerCAmelCase__ )

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

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

														_a     					=    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] )

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

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

														self.play(FadeOut(lowerCAmelCase__ ) )

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

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

														self.wait()







'''simple docstring'''


from typing import TYPE_CHECKING

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


_snake_case				:				Dict       							=		{
    'configuration_albert': ['ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AlbertConfig', 'AlbertOnnxConfig'],
}

try:
				if not is_sentencepiece_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_snake_case				:				Optional[int]       							=		['AlbertTokenizer']

try:
				if not is_tokenizers_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_snake_case				:				str       							=		['AlbertTokenizerFast']

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_snake_case				:				str       							=		[
				    'ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'AlbertForMaskedLM',
				    'AlbertForMultipleChoice',
				    'AlbertForPreTraining',
				    'AlbertForQuestionAnswering',
				    'AlbertForSequenceClassification',
				    'AlbertForTokenClassification',
				    'AlbertModel',
				    'AlbertPreTrainedModel',
				    'load_tf_weights_in_albert',
				]

try:
				if not is_tf_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_snake_case				:				Any       							=		[
				    'TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'TFAlbertForMaskedLM',
				    'TFAlbertForMultipleChoice',
				    'TFAlbertForPreTraining',
				    'TFAlbertForQuestionAnswering',
				    'TFAlbertForSequenceClassification',
				    'TFAlbertForTokenClassification',
				    'TFAlbertMainLayer',
				    'TFAlbertModel',
				    'TFAlbertPreTrainedModel',
				]

try:
				if not is_flax_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_snake_case				:				Any       							=		[
				    'FlaxAlbertForMaskedLM',
				    'FlaxAlbertForMultipleChoice',
				    'FlaxAlbertForPreTraining',
				    'FlaxAlbertForQuestionAnswering',
				    'FlaxAlbertForSequenceClassification',
				    'FlaxAlbertForTokenClassification',
				    'FlaxAlbertModel',
				    'FlaxAlbertPreTrainedModel',
				]

if TYPE_CHECKING:
				from .configuration_albert import ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, AlbertConfig, AlbertOnnxConfig

				try:
								if not is_sentencepiece_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .tokenization_albert import AlbertTokenizer

				try:
								if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .tokenization_albert_fast import AlbertTokenizerFast

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_albert import (
								    ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
								    AlbertForMaskedLM,
								    AlbertForMultipleChoice,
								    AlbertForPreTraining,
								    AlbertForQuestionAnswering,
								    AlbertForSequenceClassification,
								    AlbertForTokenClassification,
								    AlbertModel,
								    AlbertPreTrainedModel,
								    load_tf_weights_in_albert,
								)

				try:
								if not is_tf_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_tf_albert import (
								    TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
								    TFAlbertForMaskedLM,
								    TFAlbertForMultipleChoice,
								    TFAlbertForPreTraining,
								    TFAlbertForQuestionAnswering,
								    TFAlbertForSequenceClassification,
								    TFAlbertForTokenClassification,
								    TFAlbertMainLayer,
								    TFAlbertModel,
								    TFAlbertPreTrainedModel,
								)

				try:
								if not is_flax_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_flax_albert import (
								    FlaxAlbertForMaskedLM,
								    FlaxAlbertForMultipleChoice,
								    FlaxAlbertForPreTraining,
								    FlaxAlbertForQuestionAnswering,
								    FlaxAlbertForSequenceClassification,
								    FlaxAlbertForTokenClassification,
								    FlaxAlbertModel,
								    FlaxAlbertPreTrainedModel,
								)
else:
				import sys

				_snake_case				:				Union[str, Any]       							=		_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

