


from manim import *


class   a__	(						lowerCAmelCase_    ):

							def 						UpperCAmelCase(   self      :     str    ):
												a_    :     Tuple										=    Rectangle(height=0.5      ,							width=0.5    )
												a_    :     Any										=    Rectangle(height=0.2_5      ,							width=0.2_5    )
												a_    :     Optional[Any]										=    Rectangle(height=0.4_6      ,							width=0.4_6    ).set_stroke(width=0    )

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

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

												a_    :     int										=    [mem.copy() for i in range(6    )]
												a_    :     int										=    VGroup(*lowerCamelCase_    ).arrange(lowerCamelCase_      ,							buff=0    )

												a_    :     str										=    Text("""Model"""      ,							font_size=2_4    )
												a_    :     Union[str, Any]										=    Group(lowerCamelCase_      ,							lowerCamelCase_    ).arrange(lowerCamelCase_      ,							buff=0.5      ,							aligned_edge=lowerCamelCase_    )
												model.move_to([3, -1.0, 0]    )
												self.add(lowerCamelCase_    )

												a_    :     Tuple										=    []
												a_    :     List[Any]										=    []
												a_    :     Optional[int]										=    []

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

																	a_    :     str										=    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_    :     List[str]										=    [mem.copy() for i in range(6    )]
												a_    :     int										=    VGroup(*lowerCamelCase_    ).arrange(lowerCamelCase_      ,							buff=0    )

												a_    :     Tuple										=    Text("""Loaded Checkpoint"""      ,							font_size=2_4    )
												a_    :     str										=    Group(lowerCamelCase_      ,							lowerCamelCase_    ).arrange(lowerCamelCase_      ,							buff=0.5      ,							aligned_edge=lowerCamelCase_    )
												checkpoint.move_to([3, 0.5, 0]    )

												self.add(lowerCamelCase_    )

												a_    :     int										=    []
												a_    :     Optional[int]										=    []

												for i, rect in enumerate(lowerCamelCase_    ):
																	a_    :     List[str]										=    fill.copy().set_fill(lowerCamelCase_      ,							opacity=0.7    )
																	target.move_to(lowerCamelCase_    )
																	ckpt_arr.append(lowerCamelCase_    )

																	a_    :     Tuple										=    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_    :     Optional[Any]										=    Square(side_length=2.2    )
												key.move_to([-5, 2, 0]    )

												a_    :     Union[str, Any]										=    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(lowerCamelCase_      ,							lowerCamelCase_    )

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

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

												a_    :     Union[str, Any]										=    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=2_4      ,							)
												step_a.move_to([2, 2, 0]    )

												a_    :     Optional[int]										=    [meta_mem.copy() for i in range(6    )]
												a_    :     Any										=    [meta_mem.copy() for i in range(6    )]
												a_    :     int										=    VGroup(*lowerCamelCase_    ).arrange(lowerCamelCase_      ,							buff=0    )
												a_    :     Dict										=    VGroup(*lowerCamelCase_    ).arrange(lowerCamelCase_      ,							buff=0    )
												a_    :     int										=    VGroup(lowerCamelCase_      ,							lowerCamelCase_    ).arrange(lowerCamelCase_      ,							buff=0    )
												a_    :     Any										=    Text("""Disk"""      ,							font_size=2_4    )
												a_    :     Optional[Any]										=    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_    :     Union[str, Any]										=    []
												for i, rect in enumerate(lowerCamelCase_    ):
																	a_    :     Dict										=    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_    :     Optional[Any]										=    MarkupText(F'''Then, the checkpoint is removed from memory\nthrough garbage collection.'''      ,							font_size=2_4    )
												step_a.move_to([2, 2, 0]    )

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

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

												self.wait()







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__lowerCamelCase        =     {
    '''configuration_pegasus_x''': ['''PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''PegasusXConfig'''],
}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       __lowerCamelCase        =     [
           '''PEGASUS_X_PRETRAINED_MODEL_ARCHIVE_LIST''',
           '''PegasusXForConditionalGeneration''',
           '''PegasusXModel''',
           '''PegasusXPreTrainedModel''',
       ]


if TYPE_CHECKING:
       from .configuration_pegasus_x import PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP, PegasusXConfig

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_pegasus_x import (
                  PEGASUS_X_PRETRAINED_MODEL_ARCHIVE_LIST,
                  PegasusXForConditionalGeneration,
                  PegasusXModel,
                  PegasusXPreTrainedModel,
              )


else:
       import sys

       __lowerCamelCase        =     _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)



