
"""simple docstring"""





from manim import *
class 						SCREAMING_SNAKE_CASE_ (						__a ):




		"""simple docstring"""





		def 	snake_case_     (     self):
				__SCREAMING_SNAKE_CASE            = Rectangle(height=0.5							,  width=0.5)
				__SCREAMING_SNAKE_CASE            = Rectangle(height=0.46							,  width=0.46).set_stroke(width=0)

				__SCREAMING_SNAKE_CASE            = Rectangle(height=0.25							,  width=0.25)

				__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=2_4)
				__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=2_4)
				__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=2_4)
				__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            = []

				for i, rect in enumerate(lowerCAmelCase__):
						__SCREAMING_SNAKE_CASE            = fill.copy().set_fill(lowerCAmelCase__							,  opacity=0.8)
						target.move_to(lowerCAmelCase__)
						model_arr.append(lowerCAmelCase__)

						__SCREAMING_SNAKE_CASE            = Rectangle(height=0.46							,  width=0.46).set_stroke(width=0.0).set_fill(lowerCAmelCase__							,  opacity=0.8)
						cpu_target.move_to(cpu_left_col_base[i])
						model_cpu_arr.append(lowerCAmelCase__)

				self.add(*lowerCAmelCase__							,  *lowerCAmelCase__)

				__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=2_4)
				__SCREAMING_SNAKE_CASE            = Group(lowerCAmelCase__							,  lowerCAmelCase__).arrange(lowerCAmelCase__							,  buff=0.5							,  aligned_edge=lowerCAmelCase__)
				disk.move_to([-4, -1.25, 0])
				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=1_8							,  )

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

				self.add(lowerCAmelCase__							,  lowerCAmelCase__)

				__SCREAMING_SNAKE_CASE            = MarkupText(
				    f"<span fgcolor='{BLUE}'>●</span> Checkpoint"							,  font_size=1_8							,  )

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

				__SCREAMING_SNAKE_CASE            = 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(lowerCAmelCase__))

				__SCREAMING_SNAKE_CASE            = Square(0.3)
				input.set_fill(lowerCAmelCase__							,  opacity=1.0)
				input.set_stroke(width=0.0)
				input.next_to(model_base[0]							,  lowerCAmelCase__							,  buff=0.5)

				self.play(Write(lowerCAmelCase__))

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

				self.play(FadeOut(lowerCAmelCase__))

				__SCREAMING_SNAKE_CASE            = Arrow(start=lowerCAmelCase__							,  end=lowerCAmelCase__							,  color=lowerCAmelCase__							,  buff=0.5)
				a.next_to(model_arr[0].get_left()							,  lowerCAmelCase__							,  buff=0.2)

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

				__SCREAMING_SNAKE_CASE            = 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(lowerCAmelCase__							,  run_time=3))

				__SCREAMING_SNAKE_CASE            = {"""run_time""": 1, """fade_in""": True, """fade_out""": True, """buff""": 0.02}

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

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

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

						__SCREAMING_SNAKE_CASE            = AnimationGroup(
						    FadeOut(lowerCAmelCase__							,  run_time=0.5)							,  MoveToTarget(lowerCAmelCase__							,  run_time=0.5)							,  FadeIn(lowerCAmelCase__							,  run_time=0.5)							,  lag_ratio=0.2)

						self.play(lowerCAmelCase__)

						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:
										__SCREAMING_SNAKE_CASE            = 0.7

								self.play(
								    Circumscribe(model_arr[i]							,  **lowerCAmelCase__)							,  Circumscribe(cpu_left_col_base[i]							,  **lowerCAmelCase__)							,  Circumscribe(cpu_left_col_base[i + 1]							,  color=lowerCAmelCase__							,  **lowerCAmelCase__)							,  Circumscribe(gpu_rect[0]							,  color=lowerCAmelCase__							,  **lowerCAmelCase__)							,  Circumscribe(model_arr[i + 1]							,  color=lowerCAmelCase__							,  **lowerCAmelCase__)							,  )
								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=lowerCAmelCase__							,  **lowerCAmelCase__)							,  Circumscribe(cpu_left_col_base[-1]							,  color=lowerCAmelCase__							,  **lowerCAmelCase__)							,  Circumscribe(gpu_rect[0]							,  color=lowerCAmelCase__							,  **lowerCAmelCase__)							,  )

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

						__SCREAMING_SNAKE_CASE            = a_c
						__SCREAMING_SNAKE_CASE            = a_c.copy()

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

				__SCREAMING_SNAKE_CASE            = 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(lowerCAmelCase__							,  run_time=3)							,  MoveToTarget(lowerCAmelCase__))

				self.wait()






"""simple docstring"""





__magic_name__       =			"0.18.2"

from .configuration_utils import ConfigMixin
from .utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_inflect_available,
    is_invisible_watermark_available,
    is_k_diffusion_available,
    is_k_diffusion_version,
    is_librosa_available,
    is_note_seq_available,
    is_onnx_available,
    is_scipy_available,
    is_torch_available,
    is_torchsde_available,
    is_transformers_available,
    is_transformers_version,
    is_unidecode_available,
    logging,
)


try:
							if not is_onnx_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							from .utils.dummy_onnx_objects import *  # noqa F403
else:
							from .pipelines import OnnxRuntimeModel

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							from .utils.dummy_pt_objects import *  # noqa F403
else:
							from .models import (
							    AutoencoderKL,
							    ControlNetModel,
							    ModelMixin,
							    PriorTransformer,
							    TaFilmDecoder,
							    TransformeraDModel,
							    UNetaDModel,
							    UNetaDConditionModel,
							    UNetaDModel,
							    UNetaDConditionModel,
							    VQModel,
							)
							from .optimization import (
							    get_constant_schedule,
							    get_constant_schedule_with_warmup,
							    get_cosine_schedule_with_warmup,
							    get_cosine_with_hard_restarts_schedule_with_warmup,
							    get_linear_schedule_with_warmup,
							    get_polynomial_decay_schedule_with_warmup,
							    get_scheduler,
							)
							from .pipelines import (
							    AudioPipelineOutput,
							    ConsistencyModelPipeline,
							    DanceDiffusionPipeline,
							    DDIMPipeline,
							    DDPMPipeline,
							    DiffusionPipeline,
							    DiTPipeline,
							    ImagePipelineOutput,
							    KarrasVePipeline,
							    LDMPipeline,
							    LDMSuperResolutionPipeline,
							    PNDMPipeline,
							    RePaintPipeline,
							    ScoreSdeVePipeline,
							)
							from .schedulers import (
							    CMStochasticIterativeScheduler,
							    DDIMInverseScheduler,
							    DDIMParallelScheduler,
							    DDIMScheduler,
							    DDPMParallelScheduler,
							    DDPMScheduler,
							    DEISMultistepScheduler,
							    DPMSolverMultistepInverseScheduler,
							    DPMSolverMultistepScheduler,
							    DPMSolverSinglestepScheduler,
							    EulerAncestralDiscreteScheduler,
							    EulerDiscreteScheduler,
							    HeunDiscreteScheduler,
							    IPNDMScheduler,
							    KarrasVeScheduler,
							    KDPMaAncestralDiscreteScheduler,
							    KDPMaDiscreteScheduler,
							    PNDMScheduler,
							    RePaintScheduler,
							    SchedulerMixin,
							    ScoreSdeVeScheduler,
							    UnCLIPScheduler,
							    UniPCMultistepScheduler,
							    VQDiffusionScheduler,
							)
							from .training_utils import EMAModel

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 .schedulers 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 .schedulers import DPMSolverSDEScheduler

try:
							if not (is_torch_available() and is_transformers_available()):
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							from .utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
							from .pipelines import (
							    AltDiffusionImgaImgPipeline,
							    AltDiffusionPipeline,
							    AudioLDMPipeline,
							    CycleDiffusionPipeline,
							    IFImgaImgPipeline,
							    IFImgaImgSuperResolutionPipeline,
							    IFInpaintingPipeline,
							    IFInpaintingSuperResolutionPipeline,
							    IFPipeline,
							    IFSuperResolutionPipeline,
							    ImageTextPipelineOutput,
							    KandinskyImgaImgPipeline,
							    KandinskyInpaintPipeline,
							    KandinskyPipeline,
							    KandinskyPriorPipeline,
							    KandinskyVaaControlnetImgaImgPipeline,
							    KandinskyVaaControlnetPipeline,
							    KandinskyVaaImgaImgPipeline,
							    KandinskyVaaInpaintPipeline,
							    KandinskyVaaPipeline,
							    KandinskyVaaPriorEmbaEmbPipeline,
							    KandinskyVaaPriorPipeline,
							    LDMTextToImagePipeline,
							    PaintByExamplePipeline,
							    SemanticStableDiffusionPipeline,
							    ShapEImgaImgPipeline,
							    ShapEPipeline,
							    StableDiffusionAttendAndExcitePipeline,
							    StableDiffusionControlNetImgaImgPipeline,
							    StableDiffusionControlNetInpaintPipeline,
							    StableDiffusionControlNetPipeline,
							    StableDiffusionDepthaImgPipeline,
							    StableDiffusionDiffEditPipeline,
							    StableDiffusionImageVariationPipeline,
							    StableDiffusionImgaImgPipeline,
							    StableDiffusionInpaintPipeline,
							    StableDiffusionInpaintPipelineLegacy,
							    StableDiffusionInstructPixaPixPipeline,
							    StableDiffusionLatentUpscalePipeline,
							    StableDiffusionLDMaDPipeline,
							    StableDiffusionModelEditingPipeline,
							    StableDiffusionPanoramaPipeline,
							    StableDiffusionParadigmsPipeline,
							    StableDiffusionPipeline,
							    StableDiffusionPipelineSafe,
							    StableDiffusionPixaPixZeroPipeline,
							    StableDiffusionSAGPipeline,
							    StableDiffusionUpscalePipeline,
							    StableUnCLIPImgaImgPipeline,
							    StableUnCLIPPipeline,
							    TextToVideoSDPipeline,
							    TextToVideoZeroPipeline,
							    UnCLIPImageVariationPipeline,
							    UnCLIPPipeline,
							    UniDiffuserModel,
							    UniDiffuserPipeline,
							    UniDiffuserTextDecoder,
							    VersatileDiffusionDualGuidedPipeline,
							    VersatileDiffusionImageVariationPipeline,
							    VersatileDiffusionPipeline,
							    VersatileDiffusionTextToImagePipeline,
							    VideoToVideoSDPipeline,
							    VQDiffusionPipeline,
							)

try:
							if not (is_torch_available() and is_transformers_available() and is_invisible_watermark_available()):
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							from .utils.dummy_torch_and_transformers_and_invisible_watermark_objects import *  # noqa F403
else:
							from .pipelines import StableDiffusionXLImgaImgPipeline, StableDiffusionXLPipeline

try:
							if not (is_torch_available() and is_transformers_available() and is_k_diffusion_available()):
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							from .utils.dummy_torch_and_transformers_and_k_diffusion_objects import *  # noqa F403
else:
							from .pipelines import StableDiffusionKDiffusionPipeline

try:
							if not (is_torch_available() and is_transformers_available() and is_onnx_available()):
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							from .utils.dummy_torch_and_transformers_and_onnx_objects import *  # noqa F403
else:
							from .pipelines import (
							    OnnxStableDiffusionImgaImgPipeline,
							    OnnxStableDiffusionInpaintPipeline,
							    OnnxStableDiffusionInpaintPipelineLegacy,
							    OnnxStableDiffusionPipeline,
							    OnnxStableDiffusionUpscalePipeline,
							    StableDiffusionOnnxPipeline,
							)

try:
							if not (is_torch_available() and is_librosa_available()):
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							from .utils.dummy_torch_and_librosa_objects import *  # noqa F403
else:
							from .pipelines import AudioDiffusionPipeline, Mel

try:
							if not (is_transformers_available() and is_torch_available() and is_note_seq_available()):
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							from .utils.dummy_transformers_and_torch_and_note_seq_objects import *  # noqa F403
else:
							from .pipelines import SpectrogramDiffusionPipeline

try:
							if not is_flax_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							from .utils.dummy_flax_objects import *  # noqa F403
else:
							from .models.controlnet_flax import FlaxControlNetModel
							from .models.modeling_flax_utils import FlaxModelMixin
							from .models.unet_ad_condition_flax import FlaxUNetaDConditionModel
							from .models.vae_flax import FlaxAutoencoderKL
							from .pipelines import FlaxDiffusionPipeline
							from .schedulers import (
							    FlaxDDIMScheduler,
							    FlaxDDPMScheduler,
							    FlaxDPMSolverMultistepScheduler,
							    FlaxKarrasVeScheduler,
							    FlaxLMSDiscreteScheduler,
							    FlaxPNDMScheduler,
							    FlaxSchedulerMixin,
							    FlaxScoreSdeVeScheduler,
							)


try:
							if not (is_flax_available() and is_transformers_available()):
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							from .utils.dummy_flax_and_transformers_objects import *  # noqa F403
else:
							from .pipelines import (
							    FlaxStableDiffusionControlNetPipeline,
							    FlaxStableDiffusionImgaImgPipeline,
							    FlaxStableDiffusionInpaintPipeline,
							    FlaxStableDiffusionPipeline,
							)

try:
							if not (is_note_seq_available()):
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							from .utils.dummy_note_seq_objects import *  # noqa F403
else:
							from .pipelines import MidiProcessor




