

'''simple docstring'''
from manim import *







class 							A__   (	A__  ):





  def 						A  (		self				:     Optional[int]			)     ->   int:





       '''simple docstring'''






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

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

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

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

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

       _SCREAMING_SNAKE_CASE							   =[]
       _SCREAMING_SNAKE_CASE							   =[]
       _SCREAMING_SNAKE_CASE							   =[]

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

            _SCREAMING_SNAKE_CASE							   =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__			)

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

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

       self.add(lowerCamelCase__			)

       _SCREAMING_SNAKE_CASE							   =[]
       _SCREAMING_SNAKE_CASE							   =[]

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

            _SCREAMING_SNAKE_CASE							   =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__			)

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

       _SCREAMING_SNAKE_CASE							   =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__			)

       _SCREAMING_SNAKE_CASE							   =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__			)

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

       _SCREAMING_SNAKE_CASE							   =[meta_mem.copy() for i in range(6			)]
       _SCREAMING_SNAKE_CASE							   =[meta_mem.copy() for i in range(6			)]
       _SCREAMING_SNAKE_CASE							   =VGroup(*lowerCamelCase__			).arrange(lowerCamelCase__							, buff=0			)
       _SCREAMING_SNAKE_CASE							   =VGroup(*lowerCamelCase__			).arrange(lowerCamelCase__							, buff=0			)
       _SCREAMING_SNAKE_CASE							   =VGroup(lowerCamelCase__							, lowerCamelCase__			).arrange(lowerCamelCase__							, buff=0			)
       _SCREAMING_SNAKE_CASE							   =Text('Disk'							, font_size=24			)
       _SCREAMING_SNAKE_CASE							   =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			)			)

       _SCREAMING_SNAKE_CASE							   =[]
       for i, rect in enumerate(lowerCamelCase__			):
            _SCREAMING_SNAKE_CASE							   =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__			)			)

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



'''simple docstring'''
from typing import TYPE_CHECKING

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


lowerCamelCase			:				Tuple 			=					{"configuration_fnet": ["FNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FNetConfig"]}

try:
     if not is_sentencepiece_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCamelCase			:				List[Any] 			=					["FNetTokenizer"]

try:
     if not is_tokenizers_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCamelCase			:				Optional[int] 			=					["FNetTokenizerFast"]

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCamelCase			:				str 			=					[
         "FNET_PRETRAINED_MODEL_ARCHIVE_LIST",
         "FNetForMaskedLM",
         "FNetForMultipleChoice",
         "FNetForNextSentencePrediction",
         "FNetForPreTraining",
         "FNetForQuestionAnswering",
         "FNetForSequenceClassification",
         "FNetForTokenClassification",
         "FNetLayer",
         "FNetModel",
         "FNetPreTrainedModel",
     ]


if TYPE_CHECKING:
     from .configuration_fnet import FNET_PRETRAINED_CONFIG_ARCHIVE_MAP, FNetConfig

     try:
          if not is_sentencepiece_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_fnet import FNetTokenizer

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_fnet_fast import FNetTokenizerFast

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_fnet import (
              FNET_PRETRAINED_MODEL_ARCHIVE_LIST,
              FNetForMaskedLM,
              FNetForMultipleChoice,
              FNetForNextSentencePrediction,
              FNetForPreTraining,
              FNetForQuestionAnswering,
              FNetForSequenceClassification,
              FNetForTokenClassification,
              FNetLayer,
              FNetModel,
              FNetPreTrainedModel,
          )


else:
     import sys

     lowerCamelCase			:				Dict 			=					_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
