

'''simple docstring'''



from manim import *



class 				_snake_case					(   a_			):

  def   _SCREAMING_SNAKE_CASE				(				self	):





      '''simple docstring'''

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

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

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

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

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

      lowerCAmelCase 						=							[]
      lowerCAmelCase 						=							[]
      lowerCAmelCase 						=							[]

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

          lowerCAmelCase 						=							Rectangle(height=0.46 / 4      , width=0.46 / 3	).set_stroke(width=0.0	).set_fill(_SCREAMING_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=_SCREAMING_SNAKE_CASE	)
              cpu_target.set_x(cpu_target.get_x() + 0.1	)
          elif i == 3:
              cpu_target.next_to(model_cpu_arr[0]      , direction=_SCREAMING_SNAKE_CASE      , buff=0.0	)
          else:
              cpu_target.next_to(model_cpu_arr[i - 1]      , direction=_SCREAMING_SNAKE_CASE      , buff=0.0	)
          self.add(_SCREAMING_SNAKE_CASE	)
          model_cpu_arr.append(_SCREAMING_SNAKE_CASE	)

      self.add(*_SCREAMING_SNAKE_CASE      , *_SCREAMING_SNAKE_CASE      , *_SCREAMING_SNAKE_CASE	)

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

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

      self.add(_SCREAMING_SNAKE_CASE	)

      lowerCAmelCase 						=							[]
      lowerCAmelCase 						=							[]

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

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

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

      lowerCAmelCase 						=							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(_SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE	)

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

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

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

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

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

      self.play(FadeOut(_SCREAMING_SNAKE_CASE	)	)

      lowerCAmelCase 						=							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(_SCREAMING_SNAKE_CASE      , run_time=3	)	)

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

      self.wait()








'''simple docstring'''



from ..utils import DummyObject, requires_backends



class 				_snake_case					(   metaclass=a_			):
  SCREAMING_SNAKE_CASE			:       int				=     ['''torch''', '''transformers''', '''onnx''']

  def __init__(				self      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(self      , ['torch', 'transformers', 'onnx']	)

  @classmethod
  def   _SCREAMING_SNAKE_CASE				(				cls      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(cls      , ['torch', 'transformers', 'onnx']	)


  @classmethod
  def   _SCREAMING_SNAKE_CASE				(				cls      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(cls      , ['torch', 'transformers', 'onnx']	)



class 				_snake_case					(   metaclass=a_			):
  SCREAMING_SNAKE_CASE			:       List[Any]				=     ['''torch''', '''transformers''', '''onnx''']

  def __init__(				self      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(self      , ['torch', 'transformers', 'onnx']	)

  @classmethod
  def   _SCREAMING_SNAKE_CASE				(				cls      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(cls      , ['torch', 'transformers', 'onnx']	)


  @classmethod
  def   _SCREAMING_SNAKE_CASE				(				cls      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(cls      , ['torch', 'transformers', 'onnx']	)



class 				_snake_case					(   metaclass=a_			):
  SCREAMING_SNAKE_CASE			:       int				=     ['''torch''', '''transformers''', '''onnx''']

  def __init__(				self      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(self      , ['torch', 'transformers', 'onnx']	)

  @classmethod
  def   _SCREAMING_SNAKE_CASE				(				cls      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(cls      , ['torch', 'transformers', 'onnx']	)


  @classmethod
  def   _SCREAMING_SNAKE_CASE				(				cls      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(cls      , ['torch', 'transformers', 'onnx']	)



class 				_snake_case					(   metaclass=a_			):
  SCREAMING_SNAKE_CASE			:       Dict				=     ['''torch''', '''transformers''', '''onnx''']

  def __init__(				self      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(self      , ['torch', 'transformers', 'onnx']	)

  @classmethod
  def   _SCREAMING_SNAKE_CASE				(				cls      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(cls      , ['torch', 'transformers', 'onnx']	)


  @classmethod
  def   _SCREAMING_SNAKE_CASE				(				cls      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(cls      , ['torch', 'transformers', 'onnx']	)



class 				_snake_case					(   metaclass=a_			):
  SCREAMING_SNAKE_CASE			:       List[Any]				=     ['''torch''', '''transformers''', '''onnx''']

  def __init__(				self      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(self      , ['torch', 'transformers', 'onnx']	)

  @classmethod
  def   _SCREAMING_SNAKE_CASE				(				cls      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(cls      , ['torch', 'transformers', 'onnx']	)


  @classmethod
  def   _SCREAMING_SNAKE_CASE				(				cls      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(cls      , ['torch', 'transformers', 'onnx']	)



class 				_snake_case					(   metaclass=a_			):
  SCREAMING_SNAKE_CASE			:       Optional[Any]				=     ['''torch''', '''transformers''', '''onnx''']

  def __init__(				self      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(self      , ['torch', 'transformers', 'onnx']	)

  @classmethod
  def   _SCREAMING_SNAKE_CASE				(				cls      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(cls      , ['torch', 'transformers', 'onnx']	)


  @classmethod
  def   _SCREAMING_SNAKE_CASE				(				cls      , *_SCREAMING_SNAKE_CASE      , **_SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      requires_backends(cls      , ['torch', 'transformers', 'onnx']	)





