





'''simple docstring'''




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:					Any							=				logging.get_logger(__name__)

_A:					List[str]							=				{"""vocab_file""": """vocab.txt""", """tokenizer_file""": """tokenizer.json"""}

_A:					int							=				[
    """small""",
    """small-base""",
    """medium""",
    """medium-base""",
    """intermediate""",
    """intermediate-base""",
    """large""",
    """large-base""",
    """xlarge""",
    """xlarge-base""",
]

_A:					Dict							=				{
    """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:					List[Any]							=				{F"""funnel-transformer/{name}""": 512 for name in _model_names}
_A:					Optional[int]							=				{F"""funnel-transformer/{name}""": {"""do_lower_case""": True} for name in _model_names}






class UpperCAmelCase							(		UpperCAmelCase_							):
    _A :			Union[str, Any]						   =       VOCAB_FILES_NAMES
    _A :			List[str]						   =       PRETRAINED_VOCAB_FILES_MAP
    _A :			Any						   =       PRETRAINED_INIT_CONFIGURATION
    _A :			Tuple						   =       FunnelTokenizer
    _A :			Any						   =       PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    _A :			int						   =       2



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

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

     __UpperCAmelCase					=   do_lower_case



    def 					__lowerCamelCase						(  self     ,			__A     ,			__A=None					):
     __UpperCAmelCase					=   [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 					__lowerCamelCase						(  self     ,			__A     ,			__A = None					):
     __UpperCAmelCase					=   [self.sep_token_id]
     __UpperCAmelCase					=   [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 					__lowerCamelCase						(  self     ,			__A     ,			__A = None					):
     __UpperCAmelCase					=   self._tokenizer.model.save(__A     ,			name=__A					)
     return tuple(__A					)












'''simple docstring'''




from typing import List, Optional

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


_A:					str							=				logging.get_logger(__name__)

_A:					Optional[Any]							=				{
    """huggingface/autoformer-tourism-monthly""": """https://huggingface.co/huggingface/autoformer-tourism-monthly/resolve/main/config.json""",
}






class UpperCAmelCase							(		UpperCAmelCase_							):
    _A :			Tuple						   =       """autoformer"""
    _A :			str						   =       {
        """hidden_size""": """d_model""",
        """num_attention_heads""": """encoder_attention_heads""",
        """num_hidden_layers""": """encoder_layers""",
    }



    def __init__(  self     ,			__A = None     ,			__A = None     ,			__A = "student_t"     ,			__A = "nll"     ,			__A = 1     ,			__A = [1, 2, 3, 4, 5, 6, 7]     ,			__A = True     ,			__A = 0     ,			__A = 0     ,			__A = 0     ,			__A = 0     ,			__A = None     ,			__A = None     ,			__A = 64     ,			__A = 2     ,			__A = 2     ,			__A = 2     ,			__A = 2     ,			__A = 32     ,			__A = 32     ,			__A = "gelu"     ,			__A = 0.1     ,			__A = 0.1     ,			__A = 0.1     ,			__A = 0.1     ,			__A = 0.1     ,			__A = 100     ,			__A = 0.0_2     ,			__A = True     ,			__A=True     ,			__A = 10     ,			__A = 25     ,			__A = 3     ,			**__A     ,			):
     # time series specific configuration
     __UpperCAmelCase					=   prediction_length
     __UpperCAmelCase					=   context_length if context_length is not None else prediction_length
     __UpperCAmelCase					=   distribution_output
     __UpperCAmelCase					=   loss
     __UpperCAmelCase					=   input_size
     __UpperCAmelCase					=   num_time_features
     __UpperCAmelCase					=   lags_sequence
     __UpperCAmelCase					=   scaling
     __UpperCAmelCase					=   num_dynamic_real_features
     __UpperCAmelCase					=   num_static_real_features
     __UpperCAmelCase					=   num_static_categorical_features
     if cardinality is not None 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`'					)
      __UpperCAmelCase					=   cardinality
     else:
      __UpperCAmelCase					=   [0]
     if embedding_dimension is not None 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`'					)
      __UpperCAmelCase					=   embedding_dimension
     else:
      __UpperCAmelCase					=   [min(50     ,			(cat + 1) // 2					) for cat in self.cardinality]
     __UpperCAmelCase					=   num_parallel_samples

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

     __UpperCAmelCase					=   dropout
     __UpperCAmelCase					=   attention_dropout
     __UpperCAmelCase					=   activation_dropout
     __UpperCAmelCase					=   encoder_layerdrop
     __UpperCAmelCase					=   decoder_layerdrop

     __UpperCAmelCase					=   activation_function
     __UpperCAmelCase					=   init_std

     __UpperCAmelCase					=   use_cache

     # Autoformer
     __UpperCAmelCase					=   label_length
     __UpperCAmelCase					=   moving_average
     __UpperCAmelCase					=   autocorrelation_factor

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




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





