

import inspect
import re
from hashlib import shaaaa
from typing import Dict, List

from .arrow import arrow
from .audiofolder import audiofolder
from .csv import csv
from .imagefolder import imagefolder
from .json import json
from .pandas import pandas
from .parquet import parquet
from .sql import sql  # noqa F401
from .text import text




def 					_lowercase     (				a_				:					List[str]				)				->	str:




					'''simple docstring'''







					__magic_name__							=    []
					for line in lines:
										__magic_name__							=    re.sub(R'#.*'					,''					,a_				)  # remove comments
										if line:
															filtered_lines.append(a_				)
					__magic_name__							=    '\n'.join(a_				)

					# Make a hash from all this code
					__magic_name__							=    full_str.encode('utf-8'				)
					return shaaaa(a_				).hexdigest()


# get importable module names and hash for caching
A__						=							{
    "csv": (csv.__name__, _hash_python_lines(inspect.getsource(csv).splitlines())),
    "json": (json.__name__, _hash_python_lines(inspect.getsource(json).splitlines())),
    "pandas": (pandas.__name__, _hash_python_lines(inspect.getsource(pandas).splitlines())),
    "parquet": (parquet.__name__, _hash_python_lines(inspect.getsource(parquet).splitlines())),
    "arrow": (arrow.__name__, _hash_python_lines(inspect.getsource(arrow).splitlines())),
    "text": (text.__name__, _hash_python_lines(inspect.getsource(text).splitlines())),
    "imagefolder": (imagefolder.__name__, _hash_python_lines(inspect.getsource(imagefolder).splitlines())),
    "audiofolder": (audiofolder.__name__, _hash_python_lines(inspect.getsource(audiofolder).splitlines())),
}

# Used to infer the module to use based on the data files extensions
A__						=							{
    ".csv": ("csv", {}),
    ".tsv": ("csv", {"sep": "\t"}),
    ".json": ("json", {}),
    ".jsonl": ("json", {}),
    ".parquet": ("parquet", {}),
    ".arrow": ("arrow", {}),
    ".txt": ("text", {}),
}
_EXTENSION_TO_MODULE.update({ext: ("imagefolder", {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ("imagefolder", {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext: ("audiofolder", {}) for ext in audiofolder.AudioFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ("audiofolder", {}) for ext in audiofolder.AudioFolder.EXTENSIONS})
A__						=							{"imagefolder", "audiofolder"}

# Used to filter data files based on extensions given a module name
A__						=							{}
for _ext, (_module, _) in _EXTENSION_TO_MODULE.items():
						_MODULE_TO_EXTENSIONS.setdefault(_module, []).append(_ext)

_MODULE_TO_EXTENSIONS["imagefolder"].append(".zip")


_MODULE_TO_EXTENSIONS["audiofolder"].append(".zip")







from typing import List, Optional, Union

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


A__						=							logging.get_logger(__name__)

A__						=							{
    "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 				__UpperCamelCase				(					SCREAMING_SNAKE_CASE			):
	_lowercase  :   Optional[int]       				=  "time_series_transformer"
	_lowercase  :   Dict       				=  {
	    "hidden_size": "d_model",
	    "num_attention_heads": "encoder_attention_heads",
	    "num_hidden_layers": "encoder_layers",
	}







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

						'''simple docstring'''





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

						# Transformer architecture configuration
						__magic_name__							=    input_size * len(__UpperCamelCase      ) + self._number_of_features
						__magic_name__							=    d_model
						__magic_name__							=    encoder_attention_heads
						__magic_name__							=    decoder_attention_heads
						__magic_name__							=    encoder_ffn_dim
						__magic_name__							=    decoder_ffn_dim
						__magic_name__							=    encoder_layers
						__magic_name__							=    decoder_layers

						__magic_name__							=    dropout
						__magic_name__							=    attention_dropout
						__magic_name__							=    activation_dropout
						__magic_name__							=    encoder_layerdrop
						__magic_name__							=    decoder_layerdrop

						__magic_name__							=    activation_function
						__magic_name__							=    init_std

						__magic_name__							=    use_cache

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







	@property
	def 	_SCREAMING_SNAKE_CASE							(   self: str      ):

						'''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
						)




