
from typing import List, Optional, Union

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


UpperCAmelCase__					:	List[str]							       =					logging.get_logger(__name__)

UpperCAmelCase__					:	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       UpperCamelCase_      (    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  ,    UpperCamelCase = None  ,    UpperCamelCase = None  ,    UpperCamelCase = "student_t"  ,    UpperCamelCase = "nll"  ,    UpperCamelCase = 1  ,    UpperCamelCase = [1, 2, 3, 4, 5, 6, 7]  ,    UpperCamelCase = "mean"  ,    UpperCamelCase = 0  ,    UpperCamelCase = 0  ,    UpperCamelCase = 0  ,    UpperCamelCase = 0  ,    UpperCamelCase = None  ,    UpperCamelCase = None  ,    UpperCamelCase = 32  ,    UpperCamelCase = 32  ,    UpperCamelCase = 2  ,    UpperCamelCase = 2  ,    UpperCamelCase = 2  ,    UpperCamelCase = 2  ,    UpperCamelCase = True  ,    UpperCamelCase = "gelu"  ,    UpperCamelCase = 64  ,    UpperCamelCase = 0.1  ,    UpperCamelCase = 0.1  ,    UpperCamelCase = 0.1  ,    UpperCamelCase = 0.1  ,    UpperCamelCase = 0.1  ,    UpperCamelCase = 1_00  ,    UpperCamelCase = 0.02  ,    UpperCamelCase=True  ,    **UpperCamelCase  ,    )			->						Union[str, Any]:
										# time series specific configuration
										UpperCamelCase__     :		List[Any]	 =					prediction_length
										UpperCamelCase__     :		int	 =					context_length or prediction_length
										UpperCamelCase__     :		Any	 =					distribution_output
										UpperCamelCase__     :		Union[str, Any]	 =					loss
										UpperCamelCase__     :		Optional[Any]	 =					input_size
										UpperCamelCase__     :		Optional[int]	 =					num_time_features
										UpperCamelCase__     :		Any	 =					lags_sequence
										UpperCamelCase__     :		Tuple	 =					scaling
										UpperCamelCase__     :		Union[str, Any]	 =					num_dynamic_real_features
										UpperCamelCase__     :		Any	 =					num_static_real_features
										UpperCamelCase__     :		int	 =					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`')
													UpperCamelCase__     :		Optional[Any]	 =					cardinality
										else:
													UpperCamelCase__     :		Tuple	 =					[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`')
													UpperCamelCase__     :		Any	 =					embedding_dimension
										else:
													UpperCamelCase__     :		List[Any]	 =					[min(50  ,    (cat + 1) // 2) for cat in self.cardinality]
										UpperCamelCase__     :		Optional[int]	 =					num_parallel_samples

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

										UpperCamelCase__     :		int	 =					dropout
										UpperCamelCase__     :		str	 =					attention_dropout
										UpperCamelCase__     :		List[Any]	 =					activation_dropout
										UpperCamelCase__     :		Tuple	 =					encoder_layerdrop
										UpperCamelCase__     :		List[Any]	 =					decoder_layerdrop

										UpperCamelCase__     :		Tuple	 =					activation_function
										UpperCamelCase__     :		str	 =					init_std

										UpperCamelCase__     :		str	 =					use_cache

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






							@property
							def 							lowerCAmelCase__			(					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 json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_funnel import FunnelTokenizer


__A							=logging.get_logger(__name__)

__A							={'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

__A							=[
    '''small''',
    '''small-base''',
    '''medium''',
    '''medium-base''',
    '''intermediate''',
    '''intermediate-base''',
    '''large''',
    '''large-base''',
    '''xlarge''',
    '''xlarge-base''',
]

__A							={
    '''vocab_file''': {
        '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/vocab.txt''',
        '''funnel-transformer/small-base''': '''https://huggingface.co/funnel-transformer/small-base/resolve/main/vocab.txt''',
        '''funnel-transformer/medium''': '''https://huggingface.co/funnel-transformer/medium/resolve/main/vocab.txt''',
        '''funnel-transformer/medium-base''': (
            '''https://huggingface.co/funnel-transformer/medium-base/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/intermediate''': (
            '''https://huggingface.co/funnel-transformer/intermediate/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/intermediate-base''': (
            '''https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/large''': '''https://huggingface.co/funnel-transformer/large/resolve/main/vocab.txt''',
        '''funnel-transformer/large-base''': '''https://huggingface.co/funnel-transformer/large-base/resolve/main/vocab.txt''',
        '''funnel-transformer/xlarge''': '''https://huggingface.co/funnel-transformer/xlarge/resolve/main/vocab.txt''',
        '''funnel-transformer/xlarge-base''': (
            '''https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/vocab.txt'''
        ),
    },
    '''tokenizer_file''': {
        '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/tokenizer.json''',
        '''funnel-transformer/small-base''': (
            '''https://huggingface.co/funnel-transformer/small-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/medium''': '''https://huggingface.co/funnel-transformer/medium/resolve/main/tokenizer.json''',
        '''funnel-transformer/medium-base''': (
            '''https://huggingface.co/funnel-transformer/medium-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/intermediate''': (
            '''https://huggingface.co/funnel-transformer/intermediate/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/intermediate-base''': (
            '''https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/large''': '''https://huggingface.co/funnel-transformer/large/resolve/main/tokenizer.json''',
        '''funnel-transformer/large-base''': (
            '''https://huggingface.co/funnel-transformer/large-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/xlarge''': '''https://huggingface.co/funnel-transformer/xlarge/resolve/main/tokenizer.json''',
        '''funnel-transformer/xlarge-base''': (
            '''https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/tokenizer.json'''
        ),
    },
}
__A							={F"""funnel-transformer/{name}""": 5_1_2 for name in _model_names}
__A							={F"""funnel-transformer/{name}""": {'''do_lower_case''': True} for name in _model_names}




class        _SCREAMING_SNAKE_CASE	( snake_case_		):
	lowerCAmelCase__   =					VOCAB_FILES_NAMES
	lowerCAmelCase__   =					PRETRAINED_VOCAB_FILES_MAP
	lowerCAmelCase__   =					PRETRAINED_INIT_CONFIGURATION
	lowerCAmelCase__   =					FunnelTokenizer
	lowerCAmelCase__   =					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
	lowerCAmelCase__   =					2



	def __init__(       self		,    lowercase=None		,    lowercase=None		,    lowercase=True		,    lowercase="<unk>"		,    lowercase="<sep>"		,    lowercase="<pad>"		,    lowercase="<cls>"		,    lowercase="<mask>"		,    lowercase="<s>"		,    lowercase="</s>"		,    lowercase=True		,    lowercase=True		,    lowercase=None		,    lowercase="##"		,    **lowercase		,    )							->			List[str]:
					super().__init__(
					    lowercase		,    tokenizer_file=lowercase		,    do_lower_case=lowercase		,    unk_token=lowercase		,    sep_token=lowercase		,    pad_token=lowercase		,    cls_token=lowercase		,    mask_token=lowercase		,    bos_token=lowercase		,    eos_token=lowercase		,    clean_text=lowercase		,    tokenize_chinese_chars=lowercase		,    strip_accents=lowercase		,    wordpieces_prefix=lowercase		,    **lowercase		,    )

					lowerCamelCase_         =     json.loads(self.backend_tokenizer.normalizer.__getstate__()					)
					if (
					    normalizer_state.get("lowercase"		,    lowercase					) != do_lower_case
					    or normalizer_state.get("strip_accents"		,    lowercase					) != strip_accents
					    or normalizer_state.get("handle_chinese_chars"		,    lowercase					) != tokenize_chinese_chars
					):
									lowerCamelCase_         =     getattr(lowercase		,    normalizer_state.pop("type"					)					)
									lowerCamelCase_         =     do_lower_case
									lowerCamelCase_         =     strip_accents
									lowerCamelCase_         =     tokenize_chinese_chars
									lowerCamelCase_         =     normalizer_class(**lowercase					)

					lowerCamelCase_         =     do_lower_case



	def        SCREAMING_SNAKE_CASE_(       self		,    lowercase		,    lowercase=None					)							->			str:
					lowerCamelCase_         =     [self.cls_token_id] + token_ids_a + [self.sep_token_id]

					if token_ids_a:
									output += token_ids_a + [self.sep_token_id]

					return output



	def        SCREAMING_SNAKE_CASE_(       self		,    lowercase		,    lowercase = None					)							->			List[int]:
					lowerCamelCase_         =     [self.sep_token_id]
					lowerCamelCase_         =     [self.cls_token_id]
					if token_ids_a is None:
									return len(cls					) * [self.cls_token_type_id] + len(token_ids_a + sep					) * [0]
					return len(cls					) * [self.cls_token_type_id] + len(token_ids_a + sep					) * [0] + len(token_ids_a + sep					) * [1]



	def        SCREAMING_SNAKE_CASE_(       self		,    lowercase		,    lowercase = None					)							->			Tuple[str]:
					lowerCamelCase_         =     self._tokenizer.model.save(lowercase		,    name=lowercase					)
					return tuple(lowercase					)


