
'''simple docstring'''

from manim import *


class  _UpperCAmelCase ( lowerCAmelCase__    ):

					"""simple docstring"""

					def 							_lowerCAmelCase  (      self ):

							'''simple docstring'''

							a_      :	Tuple      =							Rectangle(height=0.5							,		width=0.5 )
							a_      :	Optional[Any]      =							Rectangle(height=0.25							,		width=0.25 )
							a_      :	List[Any]      =							Rectangle(height=0.46							,		width=0.46 ).set_stroke(width=0 )

							a_      :	Optional[Any]      =							[mem.copy() for i in range(6 )]
							a_      :	Union[str, Any]      =							[mem.copy() for i in range(6 )]
							a_      :	Optional[Any]      =							VGroup(*lowerCAmelCase_ ).arrange(lowerCAmelCase_							,		buff=0 )
							a_      :	List[Any]      =							VGroup(*lowerCAmelCase_ ).arrange(lowerCAmelCase_							,		buff=0 )
							a_      :	Optional[Any]      =							VGroup(lowerCAmelCase_							,		lowerCAmelCase_ ).arrange(lowerCAmelCase_							,		buff=0 )
							a_      :	Optional[Any]      =							Text("""CPU"""							,		font_size=24 )
							a_      :	Optional[int]      =							Group(lowerCAmelCase_							,		lowerCAmelCase_ ).arrange(lowerCAmelCase_							,		buff=0.5							,		aligned_edge=lowerCAmelCase_ )
							cpu.move_to([-2.5, -0.5, 0] )
							self.add(lowerCAmelCase_ )

							a_      :	Union[str, Any]      =							[mem.copy() for i in range(4 )]
							a_      :	List[str]      =							VGroup(*lowerCAmelCase_ ).arrange(lowerCAmelCase_							,		buff=0 )
							a_      :	Union[str, Any]      =							Text("""GPU"""							,		font_size=24 )
							a_      :	Union[str, Any]      =							Group(lowerCAmelCase_							,		lowerCAmelCase_ ).arrange(lowerCAmelCase_							,		buff=0.5							,		aligned_edge=lowerCAmelCase_ )
							gpu.move_to([-1, -1, 0] )
							self.add(lowerCAmelCase_ )

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

							a_      :	str      =							Text("""Model"""							,		font_size=24 )
							a_      :	Dict      =							Group(lowerCAmelCase_							,		lowerCAmelCase_ ).arrange(lowerCAmelCase_							,		buff=0.5							,		aligned_edge=lowerCAmelCase_ )
							model.move_to([3, -1.0, 0] )
							self.add(lowerCAmelCase_ )

							a_      :	List[str]      =							[]
							a_      :	List[str]      =							[]
							a_      :	List[Any]      =							[]

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

									a_      :	Optional[Any]      =							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_ )

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

							a_      :	List[Any]      =							Text("""Loaded Checkpoint"""							,		font_size=24 )
							a_      :	Tuple      =							Group(lowerCAmelCase_							,		lowerCAmelCase_ ).arrange(lowerCAmelCase_							,		buff=0.5							,		aligned_edge=lowerCAmelCase_ )
							checkpoint.move_to([3, 0.5, 0] )

							self.add(lowerCAmelCase_ )

							a_      :	List[str]      =							[]
							a_      :	str      =							[]

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

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

							a_      :	Optional[int]      =							Square(side_length=2.2 )
							key.move_to([-5, 2, 0] )

							a_      :	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(lowerCAmelCase_							,		lowerCAmelCase_ )

							a_      :	Optional[int]      =							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_ )

							a_      :	Optional[Any]      =							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] )

							a_      :	List[str]      =							[meta_mem.copy() for i in range(6 )]
							a_      :	List[Any]      =							[meta_mem.copy() for i in range(6 )]
							a_      :	str      =							VGroup(*lowerCAmelCase_ ).arrange(lowerCAmelCase_							,		buff=0 )
							a_      :	Union[str, Any]      =							VGroup(*lowerCAmelCase_ ).arrange(lowerCAmelCase_							,		buff=0 )
							a_      :	Tuple      =							VGroup(lowerCAmelCase_							,		lowerCAmelCase_ ).arrange(lowerCAmelCase_							,		buff=0 )
							a_      :	int      =							Text("""Disk"""							,		font_size=24 )
							a_      :	List[Any]      =							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 ) )

							a_      :	int      =							[]
							for i, rect in enumerate(lowerCAmelCase_ ):
									a_      :	int      =							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_ ) )

							a_      :	Optional[Any]      =							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 dataclasses import dataclass
from enum import Enum
from typing import List, Optional, Union

import numpy as np
import PIL
from PIL import Image

from ...utils import BaseOutput, is_torch_available, is_transformers_available


@dataclass
class  _UpperCAmelCase ( lowerCAmelCase__    ):

     """simple docstring"""

     a_    	=					42
     a_    	=					42


if is_transformers_available() and is_torch_available():
    from .pipeline_semantic_stable_diffusion import SemanticStableDiffusionPipeline


