




from typing import List, Optional, Union

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


UpperCAmelCase_		:				List[Any]									=     logging.get_logger(__name__)

UpperCAmelCase_		:				Optional[Any]									=     {
    "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 		__A      (			UpperCamelCase__			):
						UpperCamelCase     						=					"""time_series_transformer"""
						UpperCamelCase     						=					{
						    """hidden_size""": """d_model""",
						    """num_attention_heads""": """encoder_attention_heads""",
						    """num_hidden_layers""": """encoder_layers""",
						}

						def __init__(		self   :str    , __snake_case   :Optional[int] = None    , __snake_case   :Optional[int] = None    , __snake_case   :str = "student_t"    , __snake_case   :str = "nll"    , __snake_case   :int = 1    , __snake_case   :List[int] = [1, 2, 3, 4, 5, 6, 7]    , __snake_case   :Optional[Union[str, bool]] = "mean"    , __snake_case   :int = 0    , __snake_case   :int = 0    , __snake_case   :int = 0    , __snake_case   :int = 0    , __snake_case   :Optional[List[int]] = None    , __snake_case   :Optional[List[int]] = None    , __snake_case   :int = 32    , __snake_case   :int = 32    , __snake_case   :int = 2    , __snake_case   :int = 2    , __snake_case   :int = 2    , __snake_case   :int = 2    , __snake_case   :bool = True    , __snake_case   :str = "gelu"    , __snake_case   :int = 64    , __snake_case   :float = 0.1    , __snake_case   :float = 0.1    , __snake_case   :float = 0.1    , __snake_case   :float = 0.1    , __snake_case   :float = 0.1    , __snake_case   :int = 1_00    , __snake_case   :float = 0.02    , __snake_case   :Optional[int]=True    , **__snake_case   :Any    , ):
										'''simple docstring'''

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

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

										__magic_name__	:	int								=dropout
										__magic_name__	:	int								=attention_dropout
										__magic_name__	:	Tuple								=activation_dropout
										__magic_name__	:	Tuple								=encoder_layerdrop
										__magic_name__	:	Optional[Any]								=decoder_layerdrop

										__magic_name__	:	str								=activation_function
										__magic_name__	:	Union[str, Any]								=init_std

										__magic_name__	:	str								=use_cache

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


						@property
						def     A__						(		self   :Optional[Any] ):
										'''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
										)










import pytest

import datasets


# Import fixture modules as plugins
UpperCAmelCase_		:				Union[str, Any]									=     ["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"]




def 		lowerCAmelCase_   (	lowerCamelCase	,     lowerCamelCase   ):
				# Mark tests as "unit" by default if not marked as "integration" (or already marked as "unit")
				for item in items:
								if any(marker in item.keywords for marker in ["""integration""", """unit"""]   ):
												continue
								item.add_marker(pytest.mark.unit   )




def 		lowerCAmelCase_   (	lowerCamelCase   ):
				config.addinivalue_line("""markers"""	,     """torchaudio_latest: mark test to run with torchaudio>=0.12"""   )




@pytest.fixture(autouse=lowerCamelCase   )
def 		lowerCAmelCase_   (	lowerCamelCase	,     lowerCamelCase   ):
				# test_hf_cache_home = tmp_path_factory.mktemp("cache")  # TODO: why a cache dir per test function does not work?
				__magic_name__	:	Tuple								=tmp_path_factory.getbasetemp() / """cache"""
				__magic_name__	:	Optional[int]								=test_hf_cache_home / """datasets"""
				__magic_name__	:	List[str]								=test_hf_cache_home / """metrics"""
				__magic_name__	:	List[str]								=test_hf_cache_home / """modules"""
				monkeypatch.setattr("""datasets.config.HF_DATASETS_CACHE"""	,     str(lowerCamelCase   )   )
				monkeypatch.setattr("""datasets.config.HF_METRICS_CACHE"""	,     str(lowerCamelCase   )   )
				monkeypatch.setattr("""datasets.config.HF_MODULES_CACHE"""	,     str(lowerCamelCase   )   )
				__magic_name__	:	Optional[Any]								=test_hf_datasets_cache / """downloads"""
				monkeypatch.setattr("""datasets.config.DOWNLOADED_DATASETS_PATH"""	,     str(lowerCamelCase   )   )
				__magic_name__	:	Tuple								=test_hf_datasets_cache / """downloads""" / """extracted"""
				monkeypatch.setattr("""datasets.config.EXTRACTED_DATASETS_PATH"""	,     str(lowerCamelCase   )   )




@pytest.fixture(autouse=lowerCamelCase	,     scope="""session"""   )
def 		lowerCAmelCase_   (	):
				datasets.disable_progress_bar()




@pytest.fixture(autouse=lowerCamelCase   )
def 		lowerCAmelCase_   (	lowerCamelCase   ):
				# don't take tests into account when counting downloads
				monkeypatch.setattr("""datasets.config.HF_UPDATE_DOWNLOAD_COUNTS"""	,     lowerCamelCase   )




@pytest.fixture
def 		lowerCAmelCase_   (	lowerCamelCase   ):
				# Required to suppress RemovedIn20Warning when feature(s) are not compatible with SQLAlchemy 2.0
				# To be removed once SQLAlchemy 2.0 supported
				monkeypatch.setattr("""sqlalchemy.util.deprecations.SILENCE_UBER_WARNING"""	,     lowerCamelCase   )




