






from manim import *
class    a   (			lowerCAmelCase_       ):



      """simple docstring"""


      def      UpperCAmelCase				(				self :      List[Any] )							->				Dict:
        __UpperCAmelCase							:     str									=  Rectangle(height=0.5		,				width=0.5 )
        __UpperCAmelCase							:     str									=  Rectangle(height=0.46		,				width=0.46 ).set_stroke(width=0 )
        __UpperCAmelCase							:     List[Any]									=  Rectangle(height=0.25		,				width=0.25 )

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

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

        __UpperCAmelCase							:     Optional[int]									=  [mem.copy() for i in range(6 )]
        __UpperCAmelCase							:     Union[str, Any]									=  VGroup(*_snake_case ).arrange(_snake_case		,				buff=0 )

        __UpperCAmelCase							:     int									=  Text("""Model"""		,				font_size=24 )
        __UpperCAmelCase							:     List[Any]									=  Group(_snake_case		,				_snake_case ).arrange(_snake_case		,				buff=0.5		,				aligned_edge=_snake_case )
        model.move_to([3, -1.0, 0] )
        self.add(_snake_case )

        __UpperCAmelCase							:     Any									=  []
        __UpperCAmelCase							:     Optional[int]									=  []

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

          __UpperCAmelCase							:     Union[str, Any]									=  Rectangle(height=0.46 / 4		,				width=0.46 / 3 ).set_stroke(width=0.0 ).set_fill(_snake_case		,				opacity=0.7 )

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

        self.add(*_snake_case		,				*_snake_case )

        __UpperCAmelCase							:     Optional[Any]									=  [meta_mem.copy() for i in range(6 )]
        __UpperCAmelCase							:     List[Any]									=  [meta_mem.copy() for i in range(6 )]
        __UpperCAmelCase							:     Dict									=  VGroup(*_snake_case ).arrange(_snake_case		,				buff=0 )
        __UpperCAmelCase							:     Tuple									=  VGroup(*_snake_case ).arrange(_snake_case		,				buff=0 )
        __UpperCAmelCase							:     int									=  VGroup(_snake_case		,				_snake_case ).arrange(_snake_case		,				buff=0 )
        __UpperCAmelCase							:     Union[str, Any]									=  Text("""Disk"""		,				font_size=24 )
        __UpperCAmelCase							:     int									=  Group(_snake_case		,				_snake_case ).arrange(_snake_case		,				buff=0.5		,				aligned_edge=_snake_case )
        disk.move_to([-4.0, -1.25, 0] )
        self.add(_snake_case		,				_snake_case )

        __UpperCAmelCase							:     str									=  []

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

        self.add(*_snake_case )

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

        __UpperCAmelCase							:     int									=  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(_snake_case		,				_snake_case )

        __UpperCAmelCase							:     Optional[int]									=  MarkupText(
            f"""<span fgcolor=\'{BLUE}\'>●</span> Checkpoint"""		,				font_size=18		,				)

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

        __UpperCAmelCase							:     Optional[int]									=  MarkupText(f"""The offloaded weights are all sent to the CPU."""		,				font_size=24 )
        step_a.move_to([2, 2, 0] )

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

        for i in range(6 ):
          __UpperCAmelCase							:     int									=  cpu_disk_arr[i]
          __UpperCAmelCase							:     Optional[Any]									=  rect.copy().set_fill(_snake_case		,				opacity=0.8 ).scale(2.0 )
          cpa.generate_target()
          cpa.target.move_to(model_base[i] )

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

            self.remove(
                *_snake_case		,				*_snake_case		,				)

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

        __UpperCAmelCase							:     Optional[Any]									=  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(_snake_case		,				run_time=3 ) )

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










from typing import TYPE_CHECKING

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


a		:	Any      					=			{
    "configuration_deta": ["DETA_PRETRAINED_CONFIG_ARCHIVE_MAP", "DetaConfig"],
}

try:
       if not is_vision_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       a		:	Optional[int]      					=			["DetaImageProcessor"]

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       a		:	Tuple      					=			[
           "DETA_PRETRAINED_MODEL_ARCHIVE_LIST",
           "DetaForObjectDetection",
           "DetaModel",
           "DetaPreTrainedModel",
       ]


if TYPE_CHECKING:
       from .configuration_deta import DETA_PRETRAINED_CONFIG_ARCHIVE_MAP, DetaConfig

       try:
              if not is_vision_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .image_processing_deta import DetaImageProcessor

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_deta import (
                  DETA_PRETRAINED_MODEL_ARCHIVE_LIST,
                  DetaForObjectDetection,
                  DetaModel,
                  DetaPreTrainedModel,
              )

else:
       import sys

       a		:	Any      					=			_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)


