


'''simple docstring'''



from manim import *






class  UpperCamelCase__(     UpperCamelCase__ ):




				def   a__(	self    :				Union[str, Any]   )->  Tuple:

										"""simple docstring"""




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

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

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

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

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

										UpperCAmelCase         =			[]
										UpperCAmelCase         =			[]
										UpperCAmelCase         =			[]

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

																UpperCAmelCase         =			Rectangle(height=0.46 / 4   ,					width=0.46 / 3   ).set_stroke(width=0.0   ).set_fill(_a   ,					opacity=0.7   )

																if i == 0:
																						cpu_target.next_to(cpu_left_col_base[0].get_corner(DOWN + LEFT   )   ,					buff=0.02   ,					direction=_a   )
																						cpu_target.set_x(cpu_target.get_x() + 0.1   )
																elif i == 3:
																						cpu_target.next_to(model_cpu_arr[0]   ,					direction=_a   ,					buff=0.0   )
																else:
																						cpu_target.next_to(model_cpu_arr[i - 1]   ,					direction=_a   ,					buff=0.0   )
																self.add(_a   )
																model_cpu_arr.append(_a   )

										self.add(*_a   ,					*_a   ,					*_a   )

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

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

										self.add(_a   )

										UpperCAmelCase         =			[]
										UpperCAmelCase         =			[]

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

																UpperCAmelCase         =			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(_a   )
										self.add(*_a   ,					*_a   )

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

										UpperCAmelCase         =			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(_a   ,					_a   )

										UpperCAmelCase         =			MarkupText(
										    F"""<span fgcolor=\'{BLUE}\'>●</span> Checkpoint"""   ,					font_size=18   ,					)

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

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

										UpperCAmelCase         =			[meta_mem.copy() for i in range(6   )]
										UpperCAmelCase         =			[meta_mem.copy() for i in range(6   )]
										UpperCAmelCase         =			VGroup(*_a   ).arrange(_a   ,					buff=0   )
										UpperCAmelCase         =			VGroup(*_a   ).arrange(_a   ,					buff=0   )
										UpperCAmelCase         =			VGroup(_a   ,					_a   ).arrange(_a   ,					buff=0   )
										UpperCAmelCase         =			Text('''Disk'''   ,					font_size=24   )
										UpperCAmelCase         =			Group(_a   ,					_a   ).arrange(_a   ,					buff=0.5   ,					aligned_edge=_a   )
										disk.move_to([-4.0, -1.25, 0]   )
										self.play(Write(_a   ,					run_time=3   )   ,					Write(_a   ,					run_time=1   )   ,					Create(_a   ,					run_time=1   )   )

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

										self.play(FadeOut(_a   )   )

										UpperCAmelCase         =			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(_a   ,					run_time=3   )   )

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

										self.wait()









'''simple docstring'''



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


_lowercase    :    Any			     =  {
    """configuration_maskformer""": ["""MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MaskFormerConfig"""],
    """configuration_maskformer_swin""": ["""MaskFormerSwinConfig"""],
}

try:
	if not is_vision_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_lowercase    :    Any			     =  ["""MaskFormerFeatureExtractor"""]
	_lowercase    :    Dict			     =  ["""MaskFormerImageProcessor"""]


try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_lowercase    :    Any			     =  [
	    """MASKFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """MaskFormerForInstanceSegmentation""",
	    """MaskFormerModel""",
	    """MaskFormerPreTrainedModel""",
	]
	_lowercase    :    List[Any]			     =  [
	    """MaskFormerSwinBackbone""",
	    """MaskFormerSwinModel""",
	    """MaskFormerSwinPreTrainedModel""",
	]

if TYPE_CHECKING:
	from .configuration_maskformer import MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, MaskFormerConfig
	from .configuration_maskformer_swin import MaskFormerSwinConfig

	try:
		if not is_vision_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .feature_extraction_maskformer import MaskFormerFeatureExtractor
		from .image_processing_maskformer import MaskFormerImageProcessor
	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_maskformer import (
		    MASKFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    MaskFormerForInstanceSegmentation,
		    MaskFormerModel,
		    MaskFormerPreTrainedModel,
		)
		from .modeling_maskformer_swin import (
		    MaskFormerSwinBackbone,
		    MaskFormerSwinModel,
		    MaskFormerSwinPreTrainedModel,
		)


else:
	import sys

	_lowercase    :    List[Any]			     =  _LazyModule(__name__, globals()["""__file__"""], _import_structure)





