






from typing import List, Optional, Union

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


__lowerCamelCase :      Any										=				logging.get_logger(__name__)

__lowerCamelCase :      Optional[Any]										=				{
    """huggingface/informer-tourism-monthly""": (
        """https://huggingface.co/huggingface/informer-tourism-monthly/resolve/main/config.json"""
    ),
    # See all Informer models at https://huggingface.co/models?filter=informer
}



class 							SCREAMING_SNAKE_CASE__						(    UpperCamelCase_						):





					"""simple docstring"""






					a_     =		"informer"
					a_     =		{
					    "hidden_size": "d_model",
					    "num_attention_heads": "encoder_attention_heads",
					    "num_hidden_layers": "encoder_layers",
					}



					def __init__( self					:  List[str]							,		__A					:  Optional[int] = None							,		__A					:  Optional[int] = None							,		__A					:  str = "student_t"							,		__A					:  str = "nll"							,		__A					:  int = 1							,		__A					:  List[int] = None							,		__A					:  Optional[Union[str, bool]] = "mean"							,		__A					:  int = 0							,		__A					:  int = 0							,		__A					:  int = 0							,		__A					:  int = 0							,		__A					:  Optional[List[int]] = None							,		__A					:  Optional[List[int]] = None							,		__A					:  int = 6_4							,		__A					:  int = 3_2							,		__A					:  int = 3_2							,		__A					:  int = 2							,		__A					:  int = 2							,		__A					:  int = 2							,		__A					:  int = 2							,		__A					:  bool = True							,		__A					:  str = "gelu"							,		__A					:  float = 0.0_5							,		__A					:  float = 0.1							,		__A					:  float = 0.1							,		__A					:  float = 0.1							,		__A					:  float = 0.1							,		__A					:  int = 1_0_0							,		__A					:  float = 0.0_2							,		__A					:  Dict=True							,		__A					:  str = "prob"							,		__A					:  int = 5							,		__A					:  bool = True							,		**__A					:  Optional[int]							,		):
												# time series specific configuration
												snake_case__			:				List[str]       =  prediction_length
												snake_case__			:				Union[str, Any]       =  context_length or prediction_length
												snake_case__			:				Tuple       =  distribution_output
												snake_case__			:				Tuple       =  loss
												snake_case__			:				List[str]       =  input_size
												snake_case__			:				Optional[int]       =  num_time_features
												snake_case__			:				Dict       =  lags_sequence if lags_sequence is not None else [1, 2, 3, 4, 5, 6, 7]
												snake_case__			:				Optional[int]       =  scaling
												snake_case__			:				Dict       =  num_dynamic_real_features
												snake_case__			:				Union[str, Any]       =  num_static_real_features
												snake_case__			:				Dict       =  num_static_categorical_features

												# set cardinality
												if cardinality and num_static_categorical_features > 0:
																			if len(__A	) != num_static_categorical_features:
																										raise ValueError(
																										    "The cardinality should be a list of the same length as `num_static_categorical_features`"	)
																			snake_case__			:				List[str]       =  cardinality
												else:
																			snake_case__			:				Optional[int]       =  [0]

												# set embedding_dimension
												if embedding_dimension and num_static_categorical_features > 0:
																			if len(__A	) != num_static_categorical_features:
																										raise ValueError(
																										    "The embedding dimension should be a list of the same length as `num_static_categorical_features`"	)
																			snake_case__			:				List[str]       =  embedding_dimension
												else:
																			snake_case__			:				Dict       =  [min(5_0							,		(cat + 1) // 2	) for cat in self.cardinality]

												snake_case__			:				List[str]       =  num_parallel_samples

												# Transformer architecture configuration
												snake_case__			:				Any       =  input_size * len(self.lags_sequence	) + self._number_of_features
												snake_case__			:				str       =  d_model
												snake_case__			:				List[str]       =  encoder_attention_heads
												snake_case__			:				List[str]       =  decoder_attention_heads
												snake_case__			:				List[Any]       =  encoder_ffn_dim
												snake_case__			:				List[str]       =  decoder_ffn_dim
												snake_case__			:				Any       =  encoder_layers
												snake_case__			:				Any       =  decoder_layers

												snake_case__			:				int       =  dropout
												snake_case__			:				Dict       =  attention_dropout
												snake_case__			:				Union[str, Any]       =  activation_dropout
												snake_case__			:				Optional[Any]       =  encoder_layerdrop
												snake_case__			:				str       =  decoder_layerdrop

												snake_case__			:				Optional[Any]       =  activation_function
												snake_case__			:				Any       =  init_std

												snake_case__			:				Optional[int]       =  use_cache

												# Informer
												snake_case__			:				Optional[int]       =  attention_type
												snake_case__			:				int       =  sampling_factor
												snake_case__			:				Union[str, Any]       =  distil

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






					@property
					def 	_lowercase					( self					:  int	):
												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
												)











import os

import pytest
from attr import dataclass


__lowerCamelCase :      Any										=				"""us-east-1"""  # defaults region



@dataclass
class 							SCREAMING_SNAKE_CASE__						:





					"""simple docstring"""






					a_     =		42
					a_     =		"arn:aws:iam::558105141721:role/sagemaker_execution_role"
					a_     =		{
					    "task_name": "mnli",
					    "per_device_train_batch_size": 1_6,
					    "per_device_eval_batch_size": 1_6,
					    "do_train": True,
					    "do_eval": True,
					    "do_predict": True,
					    "output_dir": "/opt/ml/model",
					    "overwrite_output_dir": True,
					    "max_steps": 5_0_0,
					    "save_steps": 5_5_0_0,
					}
					a_     =		{**hyperparameters, "max_steps": 1_0_0_0}



					@property
					def 	_lowercase					( self					:  List[Any]	):
						if self.framework == "pytorch":
							return [
							    {"Name": "train_runtime", "Regex": r"train_runtime.*=\D*(.*?)$"},
							    {"Name": "eval_accuracy", "Regex": r"eval_accuracy.*=\D*(.*?)$"},
							    {"Name": "eval_loss", "Regex": r"eval_loss.*=\D*(.*?)$"},
							]
						else:
							return [
							    {"Name": "train_runtime", "Regex": r"train_runtime.*=\D*(.*?)$"},
							    {"Name": "eval_accuracy", "Regex": r"loss.*=\D*(.*?)]?$"},
							    {"Name": "eval_loss", "Regex": r"sparse_categorical_accuracy.*=\D*(.*?)]?$"},
							]



					@property
					def 	_lowercase					( self					:  Any	):
						return f'''{self.framework}-transfromers-test'''



					@property
					def 	_lowercase					( self					:  Optional[Any]	):
						return f'''./tests/sagemaker/scripts/{self.framework}'''






					@property
					def 	_lowercase					( self					:  Union[str, Any]	):
						if self.framework == "pytorch":
							return "763104351884.dkr.ecr.us-east-1.amazonaws.com/huggingface-pytorch-training:1.7.1-transformers4.6.1-gpu-py36-cu110-ubuntu18.04"
						else:
							return "763104351884.dkr.ecr.us-east-1.amazonaws.com/huggingface-tensorflow-training:2.4.1-transformers4.6.1-gpu-py37-cu110-ubuntu18.04"







@pytest.fixture(scope="class"       )
def 					SCREAMING_SNAKE_CASE    (			snake_case_ :							Optional[Any]       ):
	snake_case__			:				Optional[int]       =  SageMakerTestEnvironment(framework=request.cls.framework       )



