"""simple docstring"""





from manim import *


class      UpperCAmelCase_	(    _a):


      def 		_UpperCAmelCase       (   self							)       ->					str:
             lowercase__			:		int       =	Rectangle(height=0.5		,			width=0.5							)
             lowercase__			:		List[Any]       =	Rectangle(height=0.46		,			width=0.46							).set_stroke(width=0							)

             lowercase__			:		Optional[Any]       =	Rectangle(height=0.25		,			width=0.25							)

             lowercase__			:		Optional[int]       =	[mem.copy() for i in range(6							)]
             lowercase__			:		Tuple       =	[mem.copy() for i in range(6							)]
             lowercase__			:		str       =	VGroup(*a							).arrange(a		,			buff=0							)
             lowercase__			:		str       =	VGroup(*a							).arrange(a		,			buff=0							)
             lowercase__			:		str       =	VGroup(a		,			a							).arrange(a		,			buff=0							)
             lowercase__			:		Dict       =	Text('CPU'		,			font_size=2_4							)
             lowercase__			:		Dict       =	Group(a		,			a							).arrange(a		,			buff=0.5		,			aligned_edge=a							)
             cpu.move_to([-2.5, -0.5, 0]							)
             self.add(a							)

             lowercase__			:		int       =	[mem.copy() for i in range(4							)]
             lowercase__			:		List[Any]       =	VGroup(*a							).arrange(a		,			buff=0							)
             lowercase__			:		List[Any]       =	Text('GPU'		,			font_size=2_4							)
             lowercase__			:		Union[str, Any]       =	Group(a		,			a							).arrange(a		,			buff=0.5		,			aligned_edge=a							)
             gpu.move_to([-1, -1, 0]							)
             self.add(a							)

             lowercase__			:		Tuple       =	[mem.copy() for i in range(6							)]
             lowercase__			:		List[Any]       =	VGroup(*a							).arrange(a		,			buff=0							)

             lowercase__			:		Union[str, Any]       =	Text('Model'		,			font_size=2_4							)
             lowercase__			:		Any       =	Group(a		,			a							).arrange(a		,			buff=0.5		,			aligned_edge=a							)
             model.move_to([3, -1.0, 0]							)
             self.add(a							)

             lowercase__			:		int       =	[]
             lowercase__			:		Tuple       =	[]

             for i, rect in enumerate(a							):
                    lowercase__			:		List[Any]       =	fill.copy().set_fill(a		,			opacity=0.8							)
                    target.move_to(a							)
                    model_arr.append(a							)

                    lowercase__			:		List[Any]       =	Rectangle(height=0.46		,			width=0.46							).set_stroke(width=0.0							).set_fill(a		,			opacity=0.8							)
                    cpu_target.move_to(cpu_left_col_base[i]							)
                    model_cpu_arr.append(a							)

             self.add(*a		,			*a							)

             lowercase__			:		Tuple       =	[meta_mem.copy() for i in range(6							)]
             lowercase__			:		List[Any]       =	[meta_mem.copy() for i in range(6							)]
             lowercase__			:		Any       =	VGroup(*a							).arrange(a		,			buff=0							)
             lowercase__			:		Any       =	VGroup(*a							).arrange(a		,			buff=0							)
             lowercase__			:		Any       =	VGroup(a		,			a							).arrange(a		,			buff=0							)
             lowercase__			:		Tuple       =	Text('Disk'		,			font_size=2_4							)
             lowercase__			:		List[str]       =	Group(a		,			a							).arrange(a		,			buff=0.5		,			aligned_edge=a							)
             disk.move_to([-4, -1.25, 0]							)
             self.add(a		,			a							)

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

             lowercase__			:		Optional[Any]       =	MarkupText(
                 f"""<b>Key:</b>\n\n<span fgcolor='{YELLOW}'>●</span> Empty Model"""		,			font_size=1_8		,			)

             key_text.move_to([-5, 2.4, 0]							)

             self.add(a		,			a							)

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

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

             lowercase__			:		str       =	MarkupText(
                 f"""Now watch as an input is passed through the model\nand how the memory is utilized and handled."""		,			font_size=2_4		,			)
             step_a.move_to([2, 2, 0]							)

             self.play(Write(a							)							)

             lowercase__			:		List[Any]       =	Square(0.3							)
             input.set_fill(a		,			opacity=1.0							)
             input.set_stroke(width=0.0							)
             input.next_to(model_base[0]		,			a		,			buff=0.5							)

             self.play(Write(a							)							)

             input.generate_target()
             input.target.next_to(model_arr[0]		,			direction=a		,			buff=0.02							)
             self.play(MoveToTarget(a							)							)

             self.play(FadeOut(a							)							)

             lowercase__			:		Any       =	Arrow(start=a		,			end=a		,			color=a		,			buff=0.5							)
             a.next_to(model_arr[0].get_left()		,			a		,			buff=0.2							)

             model_cpu_arr[0].generate_target()
             model_cpu_arr[0].target.move_to(gpu_rect[0]							)

             lowercase__			:		List[str]       =	MarkupText(
                 f"""As the input reaches a layer, the hook triggers\nand weights are moved from the CPU\nto the GPU and back."""		,			font_size=2_4		,			)
             step_a.move_to([2, 2, 0]							)

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

             lowercase__			:		Optional[Any]       =	{'run_time': 1, 'fade_in': True, 'fade_out': True, 'buff': 0.02}

             self.play(
                 Write(a							)		,			Circumscribe(model_arr[0]		,			color=a		,			**a							)		,			Circumscribe(model_cpu_arr[0]		,			color=a		,			**a							)		,			Circumscribe(gpu_rect[0]		,			color=a		,			**a							)		,			)
             self.play(MoveToTarget(model_cpu_arr[0]							)							)

             lowercase__			:		Tuple       =	a.copy()
             for i in range(6							):
                    a_c.next_to(model_arr[i].get_right() + 0.02		,			a		,			buff=0.2							)

                    input.generate_target()
                    input.target.move_to(model_arr[i].get_right() + 0.02							)

                    lowercase__			:		Union[str, Any]       =	AnimationGroup(
                        FadeOut(a		,			run_time=0.5							)		,			MoveToTarget(a		,			run_time=0.5							)		,			FadeIn(a		,			run_time=0.5							)		,			lag_ratio=0.2							)

                    self.play(a							)

                    model_cpu_arr[i].generate_target()
                    model_cpu_arr[i].target.move_to(cpu_left_col_base[i]							)

                    if i < 5:
                           model_cpu_arr[i + 1].generate_target()
                           model_cpu_arr[i + 1].target.move_to(gpu_rect[0]							)
                           if i >= 1:
                                  lowercase__			:		List[str]       =	0.7

                           self.play(
                               Circumscribe(model_arr[i]		,			**a							)		,			Circumscribe(cpu_left_col_base[i]		,			**a							)		,			Circumscribe(cpu_left_col_base[i + 1]		,			color=a		,			**a							)		,			Circumscribe(gpu_rect[0]		,			color=a		,			**a							)		,			Circumscribe(model_arr[i + 1]		,			color=a		,			**a							)		,			)
                           if i < 1:
                                  self.play(
                                      MoveToTarget(model_cpu_arr[i]							)		,			MoveToTarget(model_cpu_arr[i + 1]							)		,			)
                           else:
                                  self.play(
                                      MoveToTarget(model_cpu_arr[i]		,			run_time=0.7							)		,			MoveToTarget(model_cpu_arr[i + 1]		,			run_time=0.7							)		,			)
                    else:
                           model_cpu_arr[i].generate_target()
                           model_cpu_arr[i].target.move_to(cpu_left_col_base[-1]							)
                           input.generate_target()
                           input.target.next_to(model_arr[-1].get_right()		,			RIGHT + 0.02		,			buff=0.2							)

                           self.play(
                               Circumscribe(model_arr[-1]		,			color=a		,			**a							)		,			Circumscribe(cpu_left_col_base[-1]		,			color=a		,			**a							)		,			Circumscribe(gpu_rect[0]		,			color=a		,			**a							)		,			)

                           self.play(MoveToTarget(model_cpu_arr[i]							)							)

                    lowercase__			:		Optional[Any]       =	a_c
                    lowercase__			:		Optional[int]       =	a_c.copy()

             input.generate_target()
             input.target.next_to(model_base[-1]		,			RIGHT + 0.02		,			buff=0.5							)
             self.play(
                 FadeOut(a							)		,			FadeOut(a		,			run_time=0.5							)		,			)

             lowercase__			:		Optional[Any]       =	MarkupText(f"""Inference on a model too large for GPU memory\nis successfully completed."""		,			font_size=2_4							)
             step_a.move_to([2, 2, 0]							)

             self.play(Write(a		,			run_time=3							)		,			MoveToTarget(a							)							)

             self.wait()








'''simple docstring'''




from ..utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_scipy_available,
    is_torch_available,
    is_torchsde_available,
)


try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  from ..utils.dummy_pt_objects import *  # noqa F403
else:
  from .scheduling_consistency_models import CMStochasticIterativeScheduler
  from .scheduling_ddim import DDIMScheduler
  from .scheduling_ddim_inverse import DDIMInverseScheduler
  from .scheduling_ddim_parallel import DDIMParallelScheduler
  from .scheduling_ddpm import DDPMScheduler
  from .scheduling_ddpm_parallel import DDPMParallelScheduler
  from .scheduling_deis_multistep import DEISMultistepScheduler
  from .scheduling_dpmsolver_multistep import DPMSolverMultistepScheduler
  from .scheduling_dpmsolver_multistep_inverse import DPMSolverMultistepInverseScheduler
  from .scheduling_dpmsolver_singlestep import DPMSolverSinglestepScheduler
  from .scheduling_euler_ancestral_discrete import EulerAncestralDiscreteScheduler
  from .scheduling_euler_discrete import EulerDiscreteScheduler
  from .scheduling_heun_discrete import HeunDiscreteScheduler
  from .scheduling_ipndm import IPNDMScheduler
  from .scheduling_k_dpm_2_ancestral_discrete import KDPMaAncestralDiscreteScheduler
  from .scheduling_k_dpm_2_discrete import KDPMaDiscreteScheduler
  from .scheduling_karras_ve import KarrasVeScheduler
  from .scheduling_pndm import PNDMScheduler
  from .scheduling_repaint import RePaintScheduler
  from .scheduling_sde_ve import ScoreSdeVeScheduler
  from .scheduling_sde_vp import ScoreSdeVpScheduler
  from .scheduling_unclip import UnCLIPScheduler
  from .scheduling_unipc_multistep import UniPCMultistepScheduler
  from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin
  from .scheduling_vq_diffusion import VQDiffusionScheduler

try:
  if not is_flax_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  from ..utils.dummy_flax_objects import *  # noqa F403
else:
  from .scheduling_ddim_flax import FlaxDDIMScheduler
  from .scheduling_ddpm_flax import FlaxDDPMScheduler
  from .scheduling_dpmsolver_multistep_flax import FlaxDPMSolverMultistepScheduler
  from .scheduling_karras_ve_flax import FlaxKarrasVeScheduler
  from .scheduling_lms_discrete_flax import FlaxLMSDiscreteScheduler
  from .scheduling_pndm_flax import FlaxPNDMScheduler
  from .scheduling_sde_ve_flax import FlaxScoreSdeVeScheduler
  from .scheduling_utils_flax import (
      FlaxKarrasDiffusionSchedulers,
      FlaxSchedulerMixin,
      FlaxSchedulerOutput,
      broadcast_to_shape_from_left,
  )


try:
  if not (is_torch_available() and is_scipy_available()):
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  from ..utils.dummy_torch_and_scipy_objects import *  # noqa F403
else:
  from .scheduling_lms_discrete import LMSDiscreteScheduler

try:
  if not (is_torch_available() and is_torchsde_available()):
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  from ..utils.dummy_torch_and_torchsde_objects import *  # noqa F403
else:
  from .scheduling_dpmsolver_sde import DPMSolverSDEScheduler




