


'''simple docstring'''

from manim import *







class 			UpperCAmelCase			(							SCREAMING_SNAKE_CASE__):

 def 		lowercase_    (			self			:						Any       ):





    """simple docstring"""



    UpperCamelCase__			    =    Rectangle(height=0.5,       width=0.5       )
    UpperCamelCase__			    =    Rectangle(height=0.46,       width=0.46       ).set_stroke(width=0       )
    UpperCamelCase__			    =    Rectangle(height=0.25,       width=0.25       )

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

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

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

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

    UpperCamelCase__			    =    []
    UpperCamelCase__			    =    []

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

       UpperCamelCase__			    =    Rectangle(height=0.46 / 4,       width=0.46 / 3       ).set_stroke(width=0.0       ).set_fill(a_,       opacity=0.7       )

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

    self.add(*a_,       *a_       )

    UpperCamelCase__			    =    [meta_mem.copy() for i in range(6       )]
    UpperCamelCase__			    =    [meta_mem.copy() for i in range(6       )]
    UpperCamelCase__			    =    VGroup(*a_       ).arrange(a_,       buff=0       )
    UpperCamelCase__			    =    VGroup(*a_       ).arrange(a_,       buff=0       )
    UpperCamelCase__			    =    VGroup(a_,       a_       ).arrange(a_,       buff=0       )
    UpperCamelCase__			    =    Text("Disk",       font_size=24       )
    UpperCamelCase__			    =    Group(a_,       a_       ).arrange(a_,       buff=0.5,       aligned_edge=a_       )
    disk.move_to([-4.0, -1.25, 0]       )
    self.add(a_,       a_       )

    UpperCamelCase__			    =    []

    for i in range(6       ):
       UpperCamelCase__			    =    fill.copy().set_fill(a_,       opacity=0.8       )
       target.move_to(disk_left_col_base[i]       ).scale(0.5       )
       cpu_disk_arr.append(a_       )

    self.add(*a_       )

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

    UpperCamelCase__			    =    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(a_,       a_       )

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

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

    UpperCamelCase__			    =    MarkupText(f'The offloaded weights are all sent to the CPU.',       font_size=24       )
    step_a.move_to([2, 2, 0]       )

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

    for i in range(6       ):
       UpperCamelCase__			    =    cpu_disk_arr[i]
       UpperCamelCase__			    =    rect.copy().set_fill(a_,       opacity=0.8       ).scale(2.0       )
       cpa.generate_target()
       cpa.target.move_to(model_base[i]       )

       if i == 0:
          rect.set_fill(a_,       opacity=0.8       )
          rect.generate_target()
          rect.target.move_to(cpu_left_col_base[0]       ).scale(2.0       )

          self.remove(
              *a_,       *a_,       )

       else:
          rect.generate_target()
          rect.target.move_to(cpu_left_col_base[i]       ).scale(2.0       )
       self.play(MoveToTarget(a_       ),       MoveToTarget(a_       ),       model_base[i].animate.set_stroke(a_       )       )
    self.play(FadeOut(a_       )       )

    UpperCamelCase__			    =    MarkupText(
        f'Finally, hooks are added to each weight in the model\nto transfer the weights from CPU to GPU\n\t\tand back when needed.',       font_size=24,       )
    step_a.move_to([2, 2, 0]       )

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

    UpperCamelCase__			    =    []
    UpperCamelCase__			    =    []
    for i in range(6       ):
       UpperCamelCase__			    =    Arrow(start=a_,       end=a_,       color=a_,       buff=0.5       )
       a.next_to(model_base[i].get_left(),       a_,       buff=0.2       )
       arrows.append(a_       )
       animations.append(Write(a_       )       )
    self.play(*a_       )
    self.wait()






"""simple docstring"""





from typing import TYPE_CHECKING

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


lowerCAmelCase__        =      {
    '''configuration_deberta_v2''': ['''DEBERTA_V2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DebertaV2Config''', '''DebertaV2OnnxConfig'''],
    '''tokenization_deberta_v2''': ['''DebertaV2Tokenizer'''],
}

try:
						if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						lowerCAmelCase__        =      ['''DebertaV2TokenizerFast''']

try:
						if not is_tf_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						lowerCAmelCase__        =      [
						    '''TF_DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''TFDebertaV2ForMaskedLM''',
						    '''TFDebertaV2ForQuestionAnswering''',
						    '''TFDebertaV2ForSequenceClassification''',
						    '''TFDebertaV2ForTokenClassification''',
						    '''TFDebertaV2Model''',
						    '''TFDebertaV2PreTrainedModel''',
						]

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						lowerCAmelCase__        =      [
						    '''DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''DebertaV2ForMaskedLM''',
						    '''DebertaV2ForMultipleChoice''',
						    '''DebertaV2ForQuestionAnswering''',
						    '''DebertaV2ForSequenceClassification''',
						    '''DebertaV2ForTokenClassification''',
						    '''DebertaV2Model''',
						    '''DebertaV2PreTrainedModel''',
						]


if TYPE_CHECKING:
						from .configuration_deberta_va import (
						    DEBERTA_V2_PRETRAINED_CONFIG_ARCHIVE_MAP,
						    DebertaVaConfig,
						    DebertaVaOnnxConfig,
						)
						from .tokenization_deberta_va import DebertaVaTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_deberta_va_fast import DebertaVaTokenizerFast

						try:
												if not is_tf_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_tf_deberta_va import (
												    TF_DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST,
												    TFDebertaVaForMaskedLM,
												    TFDebertaVaForQuestionAnswering,
												    TFDebertaVaForSequenceClassification,
												    TFDebertaVaForTokenClassification,
												    TFDebertaVaModel,
												    TFDebertaVaPreTrainedModel,
												)

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_deberta_va import (
												    DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST,
												    DebertaVaForMaskedLM,
												    DebertaVaForMultipleChoice,
												    DebertaVaForQuestionAnswering,
												    DebertaVaForSequenceClassification,
												    DebertaVaForTokenClassification,
												    DebertaVaModel,
												    DebertaVaPreTrainedModel,
												)

else:
						import sys

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






