


'''simple docstring'''







from typing import List, Optional, Union

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


A__:    Optional[Any]					    =       logging.get_logger(__name__)

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






      def __init__( self			:Union[str, Any]     ,						SCREAMING_SNAKE_CASE			:str = None     ,						SCREAMING_SNAKE_CASE			:Optional[Any] = None     ,						SCREAMING_SNAKE_CASE			:Union[str, Any] = "student_t"     ,						SCREAMING_SNAKE_CASE			:int = "nll"     ,						SCREAMING_SNAKE_CASE			:List[str] = 1     ,						SCREAMING_SNAKE_CASE			:Optional[int] = [1, 2, 3, 4, 5, 6, 7]     ,						SCREAMING_SNAKE_CASE			:Optional[int] = "mean"     ,						SCREAMING_SNAKE_CASE			:Optional[int] = 0     ,						SCREAMING_SNAKE_CASE			:Tuple = 0     ,						SCREAMING_SNAKE_CASE			:Union[str, Any] = 0     ,						SCREAMING_SNAKE_CASE			:Any = 0     ,						SCREAMING_SNAKE_CASE			:List[Any] = None     ,						SCREAMING_SNAKE_CASE			:int = None     ,						SCREAMING_SNAKE_CASE			:Dict = 3_2     ,						SCREAMING_SNAKE_CASE			:Dict = 3_2     ,						SCREAMING_SNAKE_CASE			:Union[str, Any] = 2     ,						SCREAMING_SNAKE_CASE			:List[str] = 2     ,						SCREAMING_SNAKE_CASE			:int = 2     ,						SCREAMING_SNAKE_CASE			:List[str] = 2     ,						SCREAMING_SNAKE_CASE			:Optional[int] = True     ,						SCREAMING_SNAKE_CASE			:Tuple = "gelu"     ,						SCREAMING_SNAKE_CASE			:List[Any] = 6_4     ,						SCREAMING_SNAKE_CASE			:str = 0.1     ,						SCREAMING_SNAKE_CASE			:Dict = 0.1     ,						SCREAMING_SNAKE_CASE			:Dict = 0.1     ,						SCREAMING_SNAKE_CASE			:Union[str, Any] = 0.1     ,						SCREAMING_SNAKE_CASE			:Optional[int] = 0.1     ,						SCREAMING_SNAKE_CASE			:Union[str, Any] = 1_0_0     ,						SCREAMING_SNAKE_CASE			:int = 0.02     ,						SCREAMING_SNAKE_CASE			:Optional[Any]=True     ,						**SCREAMING_SNAKE_CASE			:Any     ,						)       ->					Optional[int]:




             '''simple docstring'''
             # time series specific configuration
             _a    : Any     					=prediction_length
             _a    : int     					=context_length or prediction_length
             _a    : Tuple     					=distribution_output
             _a    : Optional[int]     					=loss
             _a    : Optional[Any]     					=input_size
             _a    : List[Any]     					=num_time_features
             _a    : str     					=lags_sequence
             _a    : Union[str, Any]     					=scaling
             _a    : List[Any]     					=num_dynamic_real_features
             _a    : Tuple     					=num_static_real_features
             _a    : Tuple     					=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`"""	)
                    _a    : str     					=cardinality
             else:
                    _a    : List[str]     					=[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`"""	)
                    _a    : Any     					=embedding_dimension
             else:
                    _a    : str     					=[min(5_0     ,						(cat + 1) // 2	) for cat in self.cardinality]
             _a    : int     					=num_parallel_samples

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

             _a    : Union[str, Any]     					=dropout
             _a    : Optional[Any]     					=attention_dropout
             _a    : Optional[Any]     					=activation_dropout
             _a    : List[str]     					=encoder_layerdrop
             _a    : List[str]     					=decoder_layerdrop

             _a    : int     					=activation_function
             _a    : List[Any]     					=init_std

             _a    : Optional[Any]     					=use_cache

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






      @property
      def __UpperCAmelCase       ( self			:Tuple	)       ->					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
             )










import importlib
import shutil
import threading
import warnings
from typing import List

import fsspec
import fsspec.asyn

from . import compression
from .hffilesystem import HfFileSystem


__UpperCAmelCase								=						importlib.util.find_spec('s3fs') is not None

if _has_safs:
		from .safilesystem import SaFileSystem  # noqa: F401

__UpperCAmelCase								=						[
    compression.BzaFileSystem,
    compression.GzipFileSystem,
    compression.LzaFileSystem,
    compression.XzFileSystem,
    compression.ZstdFileSystem,
]

# Register custom filesystems
for fs_class in COMPRESSION_FILESYSTEMS + [HfFileSystem]:
		if fs_class.protocol in fsspec.registry and fsspec.registry[fs_class.protocol] is not fs_class:
				warnings.warn(F'A filesystem protocol was already set for {fs_class.protocol} and will be overwritten.')
		fsspec.register_implementation(fs_class.protocol, fs_class, clobber=True)




def      lowercase__      (     __snake_case    :							str  ):


					'''simple docstring'''


					if "://" in dataset_path:
										UpperCAmelCase_    :      int            =						dataset_path.split('://'  )[1]
					return dataset_path




def      lowercase__      (     __snake_case    :							fsspec.AbstractFileSystem  ):


					'''simple docstring'''


					if fs is not None and fs.protocol != "file":
										return True
					else:
										return False




def      lowercase__      (     __snake_case    :							fsspec.AbstractFileSystem     ,       __snake_case    :							str     ,       __snake_case    :							str  ):


					'''simple docstring'''


					UpperCAmelCase_    :      List[str]            =						not is_remote_filesystem(__snake_case  )
					if is_local:
										# LocalFileSystem.mv does copy + rm, it is more efficient to simply move a local directory
										shutil.move(fs._strip_protocol(__snake_case  )     ,       fs._strip_protocol(__snake_case  )  )
					else:
										fs.mv(__snake_case     ,       __snake_case     ,       recursive=__snake_case  )






def      lowercase__      (     ):


					'''simple docstring'''


					if hasattr(fsspec.asyn     ,       'reset_lock'  ):
										# for future fsspec>2022.05.0
										fsspec.asyn.reset_lock()
					else:
										UpperCAmelCase_    :      Optional[Any]            =						None
										UpperCAmelCase_    :      Union[str, Any]            =						None
										UpperCAmelCase_    :      int            =						threading.Lock()






