




"""simple docstring"""


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available


A_						=				{
    '''configuration_longt5''': ['''LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LongT5Config''', '''LongT5OnnxConfig'''],
}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     A_						=				[
         '''LONGT5_PRETRAINED_MODEL_ARCHIVE_LIST''',
         '''LongT5EncoderModel''',
         '''LongT5ForConditionalGeneration''',
         '''LongT5Model''',
         '''LongT5PreTrainedModel''',
     ]

try:
     if not is_flax_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     A_						=				[
         '''FlaxLongT5ForConditionalGeneration''',
         '''FlaxLongT5Model''',
         '''FlaxLongT5PreTrainedModel''',
     ]


if TYPE_CHECKING:
     from .configuration_longta import LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP, LongTaConfig, LongTaOnnxConfig

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_longta import (
              LONGT5_PRETRAINED_MODEL_ARCHIVE_LIST,
              LongTaEncoderModel,
              LongTaForConditionalGeneration,
              LongTaModel,
              LongTaPreTrainedModel,
          )

     try:
          if not is_flax_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_flax_longta import (
              FlaxLongTaForConditionalGeneration,
              FlaxLongTaModel,
              FlaxLongTaPreTrainedModel,
          )


else:
     import sys

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







from manim import *






class SCREAMING_SNAKE_CASE__     (		SCREAMING_SNAKE_CASE__    ):




    '''simple docstring'''






    def 			_lowerCAmelCase					(       self		):
        A :       Union[str, Any]          =   Rectangle(height=0.5,		width=0.5		)
        A :       Optional[int]          =   Rectangle(height=0.25,		width=0.25		)
        A :       Optional[Any]          =   Rectangle(height=0.46,		width=0.46		).set_stroke(width=0		)

        A :       List[str]          =   [mem.copy() for i in range(6		)]
        A :       Any          =   [mem.copy() for i in range(6		)]
        A :       int          =   VGroup(*lowerCamelCase__		).arrange(lowerCamelCase__,		buff=0		)
        A :       Tuple          =   VGroup(*lowerCamelCase__		).arrange(lowerCamelCase__,		buff=0		)
        A :       str          =   VGroup(lowerCamelCase__,		lowerCamelCase__		).arrange(lowerCamelCase__,		buff=0		)
        A :       List[Any]          =   Text("""CPU""",		font_size=24		)
        A :       Optional[int]          =   Group(lowerCamelCase__,		lowerCamelCase__		).arrange(lowerCamelCase__,		buff=0.5,		aligned_edge=lowerCamelCase__		)
        cpu.move_to([-2.5, -0.5, 0]		)
        self.add(lowerCamelCase__		)

        A :       List[Any]          =   [mem.copy() for i in range(4		)]
        A :       Optional[Any]          =   VGroup(*lowerCamelCase__		).arrange(lowerCamelCase__,		buff=0		)
        A :       Dict          =   Text("""GPU""",		font_size=24		)
        A :       Any          =   Group(lowerCamelCase__,		lowerCamelCase__		).arrange(lowerCamelCase__,		buff=0.5,		aligned_edge=lowerCamelCase__		)
        gpu.move_to([-1, -1, 0]		)
        self.add(lowerCamelCase__		)

        A :       Optional[int]          =   [mem.copy() for i in range(6		)]
        A :       List[str]          =   VGroup(*lowerCamelCase__		).arrange(lowerCamelCase__,		buff=0		)

        A :       Optional[int]          =   Text("""Model""",		font_size=24		)
        A :       List[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 :       Tuple          =   []
        A :       Any          =   []

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

            A :       Any          =   Rectangle(height=0.46 / 4,		width=0.46 / 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.02,		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 :       int          =   [mem.copy() for i in range(6		)]
        A :       List[Any]          =   VGroup(*lowerCamelCase__		).arrange(lowerCamelCase__,		buff=0		)

        A :       str          =   Text("""Loaded Checkpoint""",		font_size=24		)
        A :       List[str]          =   Group(lowerCamelCase__,		lowerCamelCase__		).arrange(lowerCamelCase__,		buff=0.5,		aligned_edge=lowerCamelCase__		)
        checkpoint.move_to([3, 0.5, 0]		)

        self.add(lowerCamelCase__		)

        A :       Optional[int]          =   []
        A :       List[Any]          =   []

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

            A :       List[Any]          =   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 :       str          =   Square(side_length=2.2		)
        key.move_to([-5, 2, 0]		)

        A :       List[Any]          =   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 :       Union[str, Any]          =   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 :       List[str]          =   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 :       List[str]          =   [meta_mem.copy() for i in range(6		)]
        A :       List[Any]          =   [meta_mem.copy() for i in range(6		)]
        A :       List[Any]          =   VGroup(*lowerCamelCase__		).arrange(lowerCamelCase__,		buff=0		)
        A :       List[str]          =   VGroup(*lowerCamelCase__		).arrange(lowerCamelCase__,		buff=0		)
        A :       Dict          =   VGroup(lowerCamelCase__,		lowerCamelCase__		).arrange(lowerCamelCase__,		buff=0		)
        A :       Optional[Any]          =   Text("""Disk""",		font_size=24		)
        A :       List[str]          =   Group(lowerCamelCase__,		lowerCamelCase__		).arrange(lowerCamelCase__,		buff=0.5,		aligned_edge=lowerCamelCase__		)
        disk.move_to([-4.0, -1.25, 0]		)
        self.play(Write(lowerCamelCase__,		run_time=3		),		Write(lowerCamelCase__,		run_time=1		),		Create(lowerCamelCase__,		run_time=1		)		)

        A :       str          =   []
        for i, rect in enumerate(lowerCamelCase__		):
            A :       Optional[Any]          =   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 :       List[str]          =   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()


