'''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									=   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}': 512 for name in _model_names}
__a									=   {f'funnel-transformer/{name}': {'do_lower_case': True} for name in _model_names}





class        A__				(			_SCREAMING_SNAKE_CASE  ):





   """simple docstring"""





   UpperCamelCase_			:		Any       							=	VOCAB_FILES_NAMES
   UpperCamelCase_			:		Optional[Any]       							=	PRETRAINED_VOCAB_FILES_MAP
   UpperCamelCase_			:		Any       							=	PRETRAINED_INIT_CONFIGURATION
   UpperCamelCase_			:		List[Any]       							=	FunnelTokenizer
   UpperCamelCase_			:		List[Any]       							=	PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   UpperCamelCase_			:		int       							=	2




   def __init__(					self	:						str		,	lowerCAmelCase__	:						Optional[Any]=None		,	lowerCAmelCase__	:						List[Any]=None		,	lowerCAmelCase__	:						Optional[Any]=True		,	lowerCAmelCase__	:						int="<unk>"		,	lowerCAmelCase__	:						Dict="<sep>"		,	lowerCAmelCase__	:						Union[str, Any]="<pad>"		,	lowerCAmelCase__	:						Optional[Any]="<cls>"		,	lowerCAmelCase__	:						List[str]="<mask>"		,	lowerCAmelCase__	:						List[str]="<s>"		,	lowerCAmelCase__	:						Optional[int]="</s>"		,	lowerCAmelCase__	:						Union[str, Any]=True		,	lowerCAmelCase__	:						int=True		,	lowerCAmelCase__	:						Tuple=None		,	lowerCAmelCase__	:						List[str]="##"		,	**lowerCAmelCase__	:						List[str]		,	)			->       List[str]:







      """simple docstring"""




      super().__init__(
          lowerCAmelCase_		,	tokenizer_file=lowerCAmelCase_		,	do_lower_case=lowerCAmelCase_		,	unk_token=lowerCAmelCase_		,	sep_token=lowerCAmelCase_		,	pad_token=lowerCAmelCase_		,	cls_token=lowerCAmelCase_		,	mask_token=lowerCAmelCase_		,	bos_token=lowerCAmelCase_		,	eos_token=lowerCAmelCase_		,	clean_text=lowerCAmelCase_		,	tokenize_chinese_chars=lowerCAmelCase_		,	strip_accents=lowerCAmelCase_		,	wordpieces_prefix=lowerCAmelCase_		,	**lowerCAmelCase_		,	)

      _UpperCAmelCase				:      List[Any]				=  json.loads(self.backend_tokenizer.normalizer.__getstate__()     )
      if (
          normalizer_state.get("lowercase"		,	lowerCAmelCase_     ) != do_lower_case
          or normalizer_state.get("strip_accents"		,	lowerCAmelCase_     ) != strip_accents
          or normalizer_state.get("handle_chinese_chars"		,	lowerCAmelCase_     ) != tokenize_chinese_chars
      ):
         _UpperCAmelCase				:      str				=  getattr(lowerCAmelCase_		,	normalizer_state.pop("type"     )     )
         _UpperCAmelCase				:      Any				=  do_lower_case
         _UpperCAmelCase				:      str				=  strip_accents
         _UpperCAmelCase				:      Any				=  tokenize_chinese_chars
         _UpperCAmelCase				:      int				=  normalizer_class(**lowerCAmelCase_     )

      _UpperCAmelCase				:      List[str]				=  do_lower_case




   def      _lowerCAmelCase						(					self	:						Dict		,	lowerCAmelCase__	:						Tuple		,	lowerCAmelCase__	:						Any=None     )			->       List[str]:







      """simple docstring"""




      _UpperCAmelCase				:      Tuple				=  [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	:						List[Any]		,	lowerCAmelCase__	:						List[Any]		,	lowerCAmelCase__	:						Any = None     )			->       List[Any]:







      """simple docstring"""




      _UpperCAmelCase				:      List[str]				=  [self.sep_token_id]
      _UpperCAmelCase				:      Optional[int]				=  [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	:						Tuple		,	lowerCAmelCase__	:						str		,	lowerCAmelCase__	:						List[Any] = None     )			->       Union[str, Any]:







      """simple docstring"""




      _UpperCAmelCase				:      Optional[Any]				=  self._tokenizer.model.save(lowerCAmelCase_		,	name=lowerCAmelCase_     )
      return tuple(lowerCAmelCase_     )







"""simple docstring"""
from typing import List, Optional, Union

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


_lowerCAmelCase       =				logging.get_logger(__name__)

_lowerCAmelCase       =				{
    "huggingface/informer-tourism-monthly": (
        "https://huggingface.co/huggingface/informer-tourism-monthly/resolve/main/config.json"
    ),
    # See all Informer models at https://huggingface.co/models?filter=informer
}



class   SCREAMING_SNAKE_CASE	(					_SCREAMING_SNAKE_CASE    ):





	"""simple docstring"""




	_A							:					Optional[Any] 			=					"""informer"""
	_A							:					Dict 			=					{
	    """hidden_size""": """d_model""",
	    """num_attention_heads""": """encoder_attention_heads""",
	    """num_hidden_layers""": """encoder_layers""",
	}





	def __init__(self  ,  lowerCAmelCase_ = None  ,  lowerCAmelCase_ = None  ,  lowerCAmelCase_ = "student_t"  ,  lowerCAmelCase_ = "nll"  ,  lowerCAmelCase_ = 1  ,  lowerCAmelCase_ = None  ,  lowerCAmelCase_ = "mean"  ,  lowerCAmelCase_ = 0  ,  lowerCAmelCase_ = 0  ,  lowerCAmelCase_ = 0  ,  lowerCAmelCase_ = 0  ,  lowerCAmelCase_ = None  ,  lowerCAmelCase_ = None  ,  lowerCAmelCase_ = 64  ,  lowerCAmelCase_ = 32  ,  lowerCAmelCase_ = 32  ,  lowerCAmelCase_ = 2  ,  lowerCAmelCase_ = 2  ,  lowerCAmelCase_ = 2  ,  lowerCAmelCase_ = 2  ,  lowerCAmelCase_ = True  ,  lowerCAmelCase_ = "gelu"  ,  lowerCAmelCase_ = 0.05  ,  lowerCAmelCase_ = 0.1  ,  lowerCAmelCase_ = 0.1  ,  lowerCAmelCase_ = 0.1  ,  lowerCAmelCase_ = 0.1  ,  lowerCAmelCase_ = 100  ,  lowerCAmelCase_ = 0.02  ,  lowerCAmelCase_=True  ,  lowerCAmelCase_ = "prob"  ,  lowerCAmelCase_ = 5  ,  lowerCAmelCase_ = True  ,  **lowerCAmelCase_  ,  ):
		# time series specific configuration
		A_		:    Optional[Any]						     = prediction_length
		A_		:    Dict						     = context_length or prediction_length
		A_		:    Dict						     = distribution_output
		A_		:    Tuple						     = loss
		A_		:    Dict						     = input_size
		A_		:    Union[str, Any]						     = num_time_features
		A_		:    List[str]						     = lags_sequence if lags_sequence is not None else [1, 2, 3, 4, 5, 6, 7]
		A_		:    Optional[int]						     = scaling
		A_		:    Optional[Any]						     = num_dynamic_real_features
		A_		:    Tuple						     = num_static_real_features
		A_		:    Tuple						     = num_static_categorical_features

		# set cardinality
		if cardinality and num_static_categorical_features > 0:
			if len(lowerCAmelCase_				) != num_static_categorical_features:
				raise ValueError(
				    """The cardinality should be a list of the same length as `num_static_categorical_features`"""				)
			A_		:    List[str]						     = cardinality
		else:
			A_		:    List[Any]						     = [0]

		# set embedding_dimension
		if embedding_dimension and num_static_categorical_features > 0:
			if len(lowerCAmelCase_				) != num_static_categorical_features:
				raise ValueError(
				    """The embedding dimension should be a list of the same length as `num_static_categorical_features`"""				)
			A_		:    int						     = embedding_dimension
		else:
			A_		:    Optional[int]						     = [min(50  ,  (cat + 1) // 2				) for cat in self.cardinality]

		A_		:    Optional[int]						     = num_parallel_samples

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

		A_		:    List[str]						     = dropout
		A_		:    List[str]						     = attention_dropout
		A_		:    Any						     = activation_dropout
		A_		:    Any						     = encoder_layerdrop
		A_		:    List[Any]						     = decoder_layerdrop

		A_		:    str						     = activation_function
		A_		:    Optional[Any]						     = init_std

		A_		:    Optional[int]						     = use_cache

		# Informer
		A_		:    Dict						     = attention_type
		A_		:    List[Any]						     = sampling_factor
		A_		:    List[Any]						     = distil

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





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

