'''simple docstring'''





from manim import *




class 		SCREAMING_SNAKE_CASE     (					SCREAMING_SNAKE_CASE	):







				'''simple docstring'''





				def  snake_case__				(						self					:						Any					)							->Optional[Any]:


										'''simple docstring'''




										_UpperCamelCase			:			Dict   			=						Rectangle(height=0.5       ,		width=0.5					)
										_UpperCamelCase			:			Tuple   			=						Rectangle(height=0.4_6       ,		width=0.4_6					).set_stroke(width=0					)

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

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

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

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

										_UpperCamelCase			:			int   			=						[]
										for i, rect in enumerate(lowercase__					):
																rect.set_stroke(lowercase__					)
																# target = fill.copy().set_fill(YELLOW, opacity=0.7)
																# target.move_to(rect)
																# self.add(target)

																_UpperCamelCase			:			Dict   			=						Rectangle(height=0.4_6 / 4       ,		width=0.4_6 / 3					).set_stroke(width=0.0					).set_fill(lowercase__       ,		opacity=0.7					)

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

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

										_UpperCamelCase			:			str   			=						Text("Loaded Checkpoint"       ,		font_size=24					)
										_UpperCamelCase			:			int   			=						Group(lowercase__       ,		lowercase__					).arrange(lowercase__       ,		aligned_edge=lowercase__       ,		buff=0.4					)
										checkpoint.move_to([3, 0.5, 0]					)

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

										_UpperCamelCase			:			str   			=						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(lowercase__       ,		lowercase__					)

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

										blue_text.next_to(lowercase__       ,		DOWN * 2.4       ,		aligned_edge=key_text.get_left()					)

										_UpperCamelCase			:			Optional[Any]   			=						MarkupText(
										    f'''Next, a <i><span fgcolor="{BLUE}">second</span></i> model is loaded into memory,\nwith the weights of a <span fgcolor="{BLUE}">single shard</span>.'''       ,		font_size=24       ,		)
										step_a.move_to([2, 2, 0]					)
										self.play(Write(lowercase__					)       ,		Write(lowercase__					)					)

										self.play(Write(lowercase__       ,		run_time=1					)       ,		Create(lowercase__       ,		run_time=1					)					)

										_UpperCamelCase			:			Union[str, Any]   			=						[]
										_UpperCamelCase			:			Tuple   			=						[]
										for i, rect in enumerate(lowercase__					):
																_UpperCamelCase			:			Dict   			=						fill.copy().set_fill(lowercase__       ,		opacity=0.7					)
																target.move_to(lowercase__					)
																first_animations.append(GrowFromCenter(lowercase__       ,		run_time=1					)					)

																_UpperCamelCase			:			Optional[Any]   			=						target.copy()
																cpu_target.generate_target()
																if i < 5:
																						cpu_target.target.move_to(cpu_left_col_base[i + 1]					)
																else:
																						cpu_target.target.move_to(cpu_right_col_base[i - 5]					)
																second_animations.append(MoveToTarget(lowercase__       ,		run_time=1.5					)					)

										self.play(*lowercase__					)
										self.play(*lowercase__					)
										self.wait()



'''simple docstring'''





from typing import List, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCAmelCase_	:		Optional[int]			=     logging.get_logger(__name__)

lowerCAmelCase_	:		Tuple			=     {
    """huggingface/time-series-transformer-tourism-monthly""": (
        """https://huggingface.co/huggingface/time-series-transformer-tourism-monthly/resolve/main/config.json"""
    ),
    # See all TimeSeriesTransformer models at https://huggingface.co/models?filter=time_series_transformer
}




class 		SCREAMING_SNAKE_CASE     (					SCREAMING_SNAKE_CASE	):







				'''simple docstring'''
				UpperCAmelCase__							=							'''time_series_transformer'''
				UpperCAmelCase__							=							{
				    '''hidden_size''': '''d_model''',
				    '''num_attention_heads''': '''encoder_attention_heads''',
				    '''num_hidden_layers''': '''encoder_layers''',
				}





				def __init__(						self					:						int       ,		lowercase__					:						Optional[int] = None       ,		lowercase__					:						Optional[int] = None       ,		lowercase__					:						str = "student_t"       ,		lowercase__					:						str = "nll"       ,		lowercase__					:						int = 1       ,		lowercase__					:						List[int] = [1, 2, 3, 4, 5, 6, 7]       ,		lowercase__					:						Optional[Union[str, bool]] = "mean"       ,		lowercase__					:						int = 0       ,		lowercase__					:						int = 0       ,		lowercase__					:						int = 0       ,		lowercase__					:						int = 0       ,		lowercase__					:						Optional[List[int]] = None       ,		lowercase__					:						Optional[List[int]] = None       ,		lowercase__					:						int = 32       ,		lowercase__					:						int = 32       ,		lowercase__					:						int = 2       ,		lowercase__					:						int = 2       ,		lowercase__					:						int = 2       ,		lowercase__					:						int = 2       ,		lowercase__					:						bool = True       ,		lowercase__					:						str = "gelu"       ,		lowercase__					:						int = 64       ,		lowercase__					:						float = 0.1       ,		lowercase__					:						float = 0.1       ,		lowercase__					:						float = 0.1       ,		lowercase__					:						float = 0.1       ,		lowercase__					:						float = 0.1       ,		lowercase__					:						int = 100       ,		lowercase__					:						float = 0.0_2       ,		lowercase__					:						Optional[int]=True       ,		**lowercase__					:						Optional[Any]       ,		)							->Optional[Any]:


										'''simple docstring'''




										_UpperCamelCase			:			int   			=						prediction_length
										_UpperCamelCase			:			Optional[Any]   			=						context_length or prediction_length
										_UpperCamelCase			:			List[str]   			=						distribution_output
										_UpperCamelCase			:			Optional[Any]   			=						loss
										_UpperCamelCase			:			Tuple   			=						input_size
										_UpperCamelCase			:			Optional[int]   			=						num_time_features
										_UpperCamelCase			:			Union[str, Any]   			=						lags_sequence
										_UpperCamelCase			:			int   			=						scaling
										_UpperCamelCase			:			Dict   			=						num_dynamic_real_features
										_UpperCamelCase			:			str   			=						num_static_real_features
										_UpperCamelCase			:			Any   			=						num_static_categorical_features
										if cardinality and num_static_categorical_features > 0:
																if len(lowercase__					) != num_static_categorical_features:
																						raise ValueError(
																						    "The cardinality should be a list of the same length as `num_static_categorical_features`"					)
																_UpperCamelCase			:			Dict   			=						cardinality
										else:
																_UpperCamelCase			:			str   			=						[0]
										if embedding_dimension and num_static_categorical_features > 0:
																if len(lowercase__					) != num_static_categorical_features:
																						raise ValueError(
																						    "The embedding dimension should be a list of the same length as `num_static_categorical_features`"					)
																_UpperCamelCase			:			int   			=						embedding_dimension
										else:
																_UpperCamelCase			:			Optional[Any]   			=						[min(50       ,		(cat + 1) // 2					) for cat in self.cardinality]
										_UpperCamelCase			:			Union[str, Any]   			=						num_parallel_samples

										# Transformer architecture configuration
										_UpperCamelCase			:			int   			=						input_size * len(lowercase__					) + self._number_of_features
										_UpperCamelCase			:			Optional[Any]   			=						d_model
										_UpperCamelCase			:			str   			=						encoder_attention_heads
										_UpperCamelCase			:			List[Any]   			=						decoder_attention_heads
										_UpperCamelCase			:			str   			=						encoder_ffn_dim
										_UpperCamelCase			:			List[str]   			=						decoder_ffn_dim
										_UpperCamelCase			:			Union[str, Any]   			=						encoder_layers
										_UpperCamelCase			:			Optional[int]   			=						decoder_layers

										_UpperCamelCase			:			int   			=						dropout
										_UpperCamelCase			:			Optional[int]   			=						attention_dropout
										_UpperCamelCase			:			int   			=						activation_dropout
										_UpperCamelCase			:			List[Any]   			=						encoder_layerdrop
										_UpperCamelCase			:			int   			=						decoder_layerdrop

										_UpperCamelCase			:			List[Any]   			=						activation_function
										_UpperCamelCase			:			Any   			=						init_std

										_UpperCamelCase			:			Optional[Any]   			=						use_cache

										super().__init__(is_encoder_decoder=lowercase__       ,		**lowercase__					)







				@property
				def  snake_case__				(						self					:						Union[str, Any]					)							->int:


										'''simple docstring'''




										return (
										    sum(self.embedding_dimension					)
										    + self.num_dynamic_real_features
										    + self.num_time_features
										    + self.num_static_real_features
										    + self.input_size * 2  # the log1p(abs(loc)) and log(scale) features
										)


