





'''simple docstring'''







from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


snake_case_  :							Union[str, Any]            =	logging.get_logger(__name__)

snake_case_  :							Optional[Any]            =	{
    "apple/mobilevit-small": "https://huggingface.co/apple/mobilevit-small/resolve/main/config.json",
    "apple/mobilevit-x-small": "https://huggingface.co/apple/mobilevit-x-small/resolve/main/config.json",
    "apple/mobilevit-xx-small": "https://huggingface.co/apple/mobilevit-xx-small/resolve/main/config.json",
    "apple/deeplabv3-mobilevit-small": (
        "https://huggingface.co/apple/deeplabv3-mobilevit-small/resolve/main/config.json"
    ),
    "apple/deeplabv3-mobilevit-x-small": (
        "https://huggingface.co/apple/deeplabv3-mobilevit-x-small/resolve/main/config.json"
    ),
    "apple/deeplabv3-mobilevit-xx-small": (
        "https://huggingface.co/apple/deeplabv3-mobilevit-xx-small/resolve/main/config.json"
    ),
    # See all MobileViT models at https://huggingface.co/models?filter=mobilevit
}


class        __a   (lowerCamelCase  ):
							__a       : Optional[Any]          =							"mobilevit"

							def __init__(				self				:  Union[str, Any]							,  __magic_name__				:  Any=3							,  __magic_name__				:  List[Any]=2_56							,  __magic_name__				:  Optional[int]=2							,  __magic_name__				:  Union[str, Any]=[1_44, 1_92, 2_40]							,  __magic_name__				:  Dict=[16, 32, 64, 96, 1_28, 1_60, 6_40]							,  __magic_name__				:  Any=4							,  __magic_name__				:  Any=2.0							,  __magic_name__				:  Dict=4.0							,  __magic_name__				:  List[str]="silu"							,  __magic_name__				:  Any=3							,  __magic_name__				:  Union[str, Any]=32							,  __magic_name__				:  int=0.1							,  __magic_name__				:  Optional[int]=0.0							,  __magic_name__				:  str=0.1							,  __magic_name__				:  int=0.0_2							,  __magic_name__				:  List[str]=1E-5							,  __magic_name__				:  str=True							,  __magic_name__				:  Tuple=2_56							,  __magic_name__				:  Union[str, Any]=[6, 12, 18]							,  __magic_name__				:  Optional[Any]=0.1							,  __magic_name__				:  Dict=2_55							,  **__magic_name__				:  Any							,  )       ->							Optional[int]:







													"""simple docstring"""
													super().__init__(**__magic_name__ )

													UpperCAmelCase_      :   Optional[int]      =	num_channels
													UpperCAmelCase_      :   Optional[Any]      =	image_size
													UpperCAmelCase_      :   Tuple      =	patch_size
													UpperCAmelCase_      :   Optional[int]      =	hidden_sizes
													UpperCAmelCase_      :   List[Any]      =	neck_hidden_sizes
													UpperCAmelCase_      :   Optional[Any]      =	num_attention_heads
													UpperCAmelCase_      :   Union[str, Any]      =	mlp_ratio
													UpperCAmelCase_      :   List[str]      =	expand_ratio
													UpperCAmelCase_      :   Union[str, Any]      =	hidden_act
													UpperCAmelCase_      :   Any      =	conv_kernel_size
													UpperCAmelCase_      :   List[str]      =	output_stride
													UpperCAmelCase_      :   Union[str, Any]      =	hidden_dropout_prob
													UpperCAmelCase_      :   Union[str, Any]      =	attention_probs_dropout_prob
													UpperCAmelCase_      :   Any      =	classifier_dropout_prob
													UpperCAmelCase_      :   Optional[int]      =	initializer_range
													UpperCAmelCase_      :   int      =	layer_norm_eps
													UpperCAmelCase_      :   List[Any]      =	qkv_bias

													# decode head attributes for semantic segmentation
													UpperCAmelCase_      :   List[str]      =	aspp_out_channels
													UpperCAmelCase_      :   Optional[Any]      =	atrous_rates
													UpperCAmelCase_      :   Tuple      =	aspp_dropout_prob
													UpperCAmelCase_      :   Optional[Any]      =	semantic_loss_ignore_index





class        __a   (lowerCamelCase  ):
							__a       : Union[str, Any]          =							version.parse("1.11"  )

							@property
							def      UpperCAmelCase__						(				self				:  Any )       ->							Mapping[str, Mapping[int, str]]:







													"""simple docstring"""
													return OrderedDict([('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''})] )

							@property
							def      UpperCAmelCase__						(				self				:  int )       ->							Mapping[str, Mapping[int, str]]:







													"""simple docstring"""
													if self.task == "image-classification":
																			return OrderedDict([('''logits''', {0: '''batch'''})] )
													else:
																			return OrderedDict([('''last_hidden_state''', {0: '''batch'''}), ('''pooler_output''', {0: '''batch'''})] )



							@property
							def      UpperCAmelCase__						(				self				:  str )       ->							float:







													"""simple docstring"""
													return 1E-4












'''simple docstring'''







from manim import *


class        __a   (lowerCamelCase  ):

							def      UpperCAmelCase__						(				self				:  str )       ->							Any:







													"""simple docstring"""
													UpperCAmelCase_      :   List[str]      =	Rectangle(height=0.5							,  width=0.5 )
													UpperCAmelCase_      :   int      =	Rectangle(height=0.4_6							,  width=0.4_6 ).set_stroke(width=0 )
													UpperCAmelCase_      :   str      =	Rectangle(height=0.2_5							,  width=0.2_5 )

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

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

													UpperCAmelCase_      :   Dict      =	[mem.copy() for i in range(6 )]
													UpperCAmelCase_      :   Optional[Any]      =	VGroup(*__magic_name__ ).arrange(__magic_name__							,  buff=0 )

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

													UpperCAmelCase_      :   List[str]      =	[]
													UpperCAmelCase_      :   int      =	[]

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

																			UpperCAmelCase_      :   List[Any]      =	Rectangle(height=0.4_6 / 4							,  width=0.4_6 / 3 ).set_stroke(width=0.0 ).set_fill(__magic_name__							,  opacity=0.7 )

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

													self.add(*__magic_name__							,  *__magic_name__ )

													UpperCAmelCase_      :   Any      =	[meta_mem.copy() for i in range(6 )]
													UpperCAmelCase_      :   int      =	[meta_mem.copy() for i in range(6 )]
													UpperCAmelCase_      :   Optional[Any]      =	VGroup(*__magic_name__ ).arrange(__magic_name__							,  buff=0 )
													UpperCAmelCase_      :   Optional[int]      =	VGroup(*__magic_name__ ).arrange(__magic_name__							,  buff=0 )
													UpperCAmelCase_      :   Dict      =	VGroup(__magic_name__							,  __magic_name__ ).arrange(__magic_name__							,  buff=0 )
													UpperCAmelCase_      :   Optional[Any]      =	Text('''Disk'''							,  font_size=24 )
													UpperCAmelCase_      :   Any      =	Group(__magic_name__							,  __magic_name__ ).arrange(__magic_name__							,  buff=0.5							,  aligned_edge=__magic_name__ )
													disk.move_to([-4.0, -1.2_5, 0] )
													self.add(__magic_name__							,  __magic_name__ )

													UpperCAmelCase_      :   Optional[Any]      =	[]

													for i in range(6 ):
																			UpperCAmelCase_      :   Tuple      =	fill.copy().set_fill(__magic_name__							,  opacity=0.8 )
																			target.move_to(disk_left_col_base[i] ).scale(0.5 )
																			cpu_disk_arr.append(__magic_name__ )

													self.add(*__magic_name__ )

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

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

													UpperCAmelCase_      :   Union[str, Any]      =	MarkupText(
													    F"""<span fgcolor='{BLUE}'>●</span> Checkpoint"""							,  font_size=18							,  )

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

													UpperCAmelCase_      :   Dict      =	MarkupText(F"""The offloaded weights are all sent to the CPU."""							,  font_size=24 )
													step_a.move_to([2, 2, 0] )

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

													for i in range(6 ):
																			UpperCAmelCase_      :   Dict      =	cpu_disk_arr[i]
																			UpperCAmelCase_      :   int      =	rect.copy().set_fill(__magic_name__							,  opacity=0.8 ).scale(2.0 )
																			cpa.generate_target()
																			cpa.target.move_to(model_base[i] )

																			if i == 0:
																									rect.set_fill(__magic_name__							,  opacity=0.8 )
																									rect.generate_target()
																									rect.target.move_to(cpu_left_col_base[0] ).scale(2.0 )

																									self.remove(
																									    *__magic_name__							,  *__magic_name__							,  )

																			else:
																									rect.generate_target()
																									rect.target.move_to(cpu_left_col_base[i] ).scale(2.0 )
																			self.play(MoveToTarget(__magic_name__ )							,  MoveToTarget(__magic_name__ )							,  model_base[i].animate.set_stroke(__magic_name__ ) )
													self.play(FadeOut(__magic_name__ ) )

													UpperCAmelCase_      :   int      =	MarkupText(
													    F"""Finally, hooks are added to each weight in the model\nto transfer the weights from CPU to GPU\n\t\tand back when needed."""							,  font_size=24							,  )
													step_a.move_to([2, 2, 0] )

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

													UpperCAmelCase_      :   Union[str, Any]      =	[]
													UpperCAmelCase_      :   Tuple      =	[]
													for i in range(6 ):
																			UpperCAmelCase_      :   List[Any]      =	Arrow(start=__magic_name__							,  end=__magic_name__							,  color=__magic_name__							,  buff=0.5 )
																			a.next_to(model_base[i].get_left()							,  __magic_name__							,  buff=0.2 )
																			arrows.append(__magic_name__ )
																			animations.append(Write(__magic_name__ ) )
													self.play(*__magic_name__ )
													self.wait()





