
from manim import *


class 						__lowerCAmelCase	(	lowerCAmelCase_      ):



      """simple docstring"""







      def 		snake_case_			(      self		:       Dict				):
          __lowercase		:			Dict	    =       Rectangle(height=0.5				,       width=0.5				)
          __lowercase		:			Dict	    =       Rectangle(height=0.25				,       width=0.25				)
          __lowercase		:			int	    =       Rectangle(height=0.46				,       width=0.46				).set_stroke(width=0				)

          __lowercase		:			Optional[int]	    =       [mem.copy() for i in range(6				)]
          __lowercase		:			Optional[int]	    =       [mem.copy() for i in range(6				)]
          __lowercase		:			Tuple	    =       VGroup(*_snake_case				).arrange(_snake_case				,       buff=0				)
          __lowercase		:			Optional[int]	    =       VGroup(*_snake_case				).arrange(_snake_case				,       buff=0				)
          __lowercase		:			int	    =       VGroup(_snake_case				,       _snake_case				).arrange(_snake_case				,       buff=0				)
          __lowercase		:			int	    =       Text('''CPU'''				,       font_size=24				)
          __lowercase		:			Union[str, Any]	    =       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				)

          __lowercase		:			int	    =       [mem.copy() for i in range(4				)]
          __lowercase		:			Union[str, Any]	    =       VGroup(*_snake_case				).arrange(_snake_case				,       buff=0				)
          __lowercase		:			Any	    =       Text('''GPU'''				,       font_size=24				)
          __lowercase		:			Union[str, 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				)

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

          __lowercase		:			int	    =       Text('''Model'''				,       font_size=24				)
          __lowercase		:			Union[str, 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				)

          __lowercase		:			Dict	    =       []
          __lowercase		:			str	    =       []
          __lowercase		:			Any	    =       []

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

              __lowercase		:			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				,       *_snake_case				)

          __lowercase		:			str	    =       [mem.copy() for i in range(6				)]
          __lowercase		:			str	    =       VGroup(*_snake_case				).arrange(_snake_case				,       buff=0				)

          __lowercase		:			int	    =       Text('''Loaded Checkpoint'''				,       font_size=24				)
          __lowercase		:			Optional[Any]	    =       Group(_snake_case				,       _snake_case				).arrange(_snake_case				,       buff=0.5				,       aligned_edge=_snake_case				)
          checkpoint.move_to([3, 0.5, 0]				)

          self.add(_snake_case				)

          __lowercase		:			Optional[Any]	    =       []
          __lowercase		:			Tuple	    =       []

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

              __lowercase		:			List[str]	    =       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(_snake_case				)
          self.add(*_snake_case				,       *_snake_case				)

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

          __lowercase		:			Tuple	    =       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				)

          __lowercase		:			Union[str, Any]	    =       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				)

          __lowercase		:			Dict	    =       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]				)

          __lowercase		:			Any	    =       [meta_mem.copy() for i in range(6				)]
          __lowercase		:			Any	    =       [meta_mem.copy() for i in range(6				)]
          __lowercase		:			Union[str, Any]	    =       VGroup(*_snake_case				).arrange(_snake_case				,       buff=0				)
          __lowercase		:			str	    =       VGroup(*_snake_case				).arrange(_snake_case				,       buff=0				)
          __lowercase		:			int	    =       VGroup(_snake_case				,       _snake_case				).arrange(_snake_case				,       buff=0				)
          __lowercase		:			Optional[Any]	    =       Text('''Disk'''				,       font_size=24				)
          __lowercase		:			Union[str, Any]	    =       Group(_snake_case				,       _snake_case				).arrange(_snake_case				,       buff=0.5				,       aligned_edge=_snake_case				)
          disk.move_to([-4.0, -1.25, 0]				)
          self.play(Write(_snake_case				,       run_time=3				)				,       Write(_snake_case				,       run_time=1				)				,       Create(_snake_case				,       run_time=1				)				)

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

          self.play(FadeOut(_snake_case				)				)

          __lowercase		:			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(_snake_case				,       run_time=3				)				)

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

          self.wait()




import logging
import os
from logging import (
    CRITICAL,  # NOQA
    DEBUG,  # NOQA
    ERROR,  # NOQA
    FATAL,  # NOQA
    INFO,  # NOQA
    NOTSET,  # NOQA
    WARN,  # NOQA
    WARNING,  # NOQA
)
from typing import Optional

from tqdm import auto as tqdm_lib


__lowerCAmelCase					:			int			      =		{
    "debug": logging.DEBUG,
    "info": logging.INFO,
    "warning": logging.WARNING,
    "error": logging.ERROR,
    "critical": logging.CRITICAL,
}

__lowerCAmelCase					:			Optional[int]			      =		logging.WARNING


def     UpperCAmelCase_  (						) ->						Optional[Any]:
    __lowercase		:			Any	    =       os.getenv('''DATASETS_VERBOSITY'''	,					__lowerCAmelCase	)
    if env_level_str:
        if env_level_str in log_levels:
            return log_levels[env_level_str]
        else:
            logging.getLogger().warning(
                F'Unknown option DATASETS_VERBOSITY={env_level_str}, '
                F'has to be one of: { ", ".join(log_levels.keys()	) }'	)
    return _default_log_level


def     UpperCAmelCase_  (						) ->						str:
    return __name__.split('''.'''	)[0]


def     UpperCAmelCase_  (						) ->						logging.Logger:
    return logging.getLogger(_get_library_name()	)


def     UpperCAmelCase_  (						) ->						None:
    # Apply our default configuration to the library root logger.
    __lowercase		:			Union[str, Any]	    =       _get_library_root_logger()
    library_root_logger.setLevel(_get_default_logging_level()	)


def     UpperCAmelCase_  (						) ->						None:
    __lowercase		:			List[Any]	    =       _get_library_root_logger()
    library_root_logger.setLevel(logging.NOTSET	)


def     UpperCAmelCase_  (						__lowerCAmelCase = None	) ->						logging.Logger:
    if name is None:
        __lowercase		:			Optional[Any]	    =       _get_library_name()
    return logging.getLogger(__lowerCAmelCase	)


def     UpperCAmelCase_  (						) ->						int:
    return _get_library_root_logger().getEffectiveLevel()


def     UpperCAmelCase_  (						__lowerCAmelCase	) ->						None:
    _get_library_root_logger().setLevel(__lowerCAmelCase	)


def     UpperCAmelCase_  (						) ->						int:
    return set_verbosity(__lowerCAmelCase	)


def     UpperCAmelCase_  (						) ->						List[str]:
    return set_verbosity(__lowerCAmelCase	)


def     UpperCAmelCase_  (						) ->						Optional[int]:
    return set_verbosity(__lowerCAmelCase	)


def     UpperCAmelCase_  (						) ->						Any:
    return set_verbosity(__lowerCAmelCase	)


def     UpperCAmelCase_  (						) ->						None:
    __lowercase		:			Tuple	    =       False


def     UpperCAmelCase_  (						) ->						None:
    __lowercase		:			Dict	    =       True


# Configure the library root logger at the module level (singleton-like)
_configure_library_root_logger()


class 						__lowerCAmelCase	:



      """simple docstring"""







      def __init__(      self		:       List[Any]				,       *_snake_case		:       List[Any]				,       **_snake_case		:       Dict				):  # pylint: disable=unused-argument
          __lowercase		:			Tuple	    =       args[0] if args else None




      def __iter__(      self		:       Tuple				):
          return iter(self._iterator				)




      def __getattr__(      self		:       Optional[int]				,       _snake_case		:       Union[str, Any]				):

          def empty_fn(*_snake_case		:       Tuple				,       **_snake_case		:       int				):  # pylint: disable=unused-argument
              return

          return empty_fn




      def __enter__(      self		:       Optional[Any]				):
          return self




      def __exit__(      self		:       Optional[Any]				,       _snake_case		:       Any				,       _snake_case		:       List[Any]				,       _snake_case		:       List[Any]				):
          return






__lowerCAmelCase					:			int			      =		True


class 						__lowerCAmelCase	:



      """simple docstring"""







      def __call__(      self		:       List[str]				,       *_snake_case		:       Dict				,       _snake_case		:       str=False				,       **_snake_case		:       List[str]				):
          if _tqdm_active and not disable:
              return tqdm_lib.tqdm(*_snake_case				,       **_snake_case				)
          else:
              return EmptyTqdm(*_snake_case				,       **_snake_case				)




      def 		snake_case_			(      self		:       Optional[Any]				,       *_snake_case		:       str				,       **_snake_case		:       List[str]				):
          __lowercase		:			Dict	    =       None
          if _tqdm_active:
              return tqdm_lib.tqdm.set_lock(*_snake_case				,       **_snake_case				)




      def 		snake_case_			(      self		:       Tuple				):
          if _tqdm_active:
              return tqdm_lib.tqdm.get_lock()






__lowerCAmelCase					:			Tuple			      =		_tqdm_cls()


def     UpperCAmelCase_  (						) ->						bool:
    global _tqdm_active
    return bool(_tqdm_active	)


def     UpperCAmelCase_  (						) ->						Union[str, Any]:
    global _tqdm_active
    __lowercase		:			Dict	    =       True





def     UpperCAmelCase_  (						) ->						Tuple:
    global _tqdm_active
    __lowercase		:			Optional[int]	    =       False


