




'''simple docstring'''







from typing import List, Optional, Union

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


A									=logging.get_logger(__name__)

A									={
    '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     _a						(			__a				):
       __a       :  int            =      """informer"""
       __a       :  str            =      {
           """hidden_size""": """d_model""",
           """num_attention_heads""": """encoder_attention_heads""",
           """num_hidden_layers""": """encoder_layers""",
       }
       def __init__(			self		:			Tuple     ,       lowercase		:			Optional[int] = None     ,       lowercase		:			Optional[int] = None     ,       lowercase		:			str = "student_t"     ,       lowercase		:			str = "nll"     ,       lowercase		:			int = 1     ,       lowercase		:			List[int] = None     ,       lowercase		:			Optional[Union[str, bool]] = "mean"     ,       lowercase		:			int = 0     ,       lowercase		:			int = 0     ,       lowercase		:			int = 0     ,       lowercase		:			int = 0     ,       lowercase		:			Optional[List[int]] = None     ,       lowercase		:			Optional[List[int]] = None     ,       lowercase		:			int = 64     ,       lowercase		:			int = 32     ,       lowercase		:			int = 32     ,       lowercase		:			int = 2     ,       lowercase		:			int = 2     ,       lowercase		:			int = 2     ,       lowercase		:			int = 2     ,       lowercase		:			bool = True     ,       lowercase		:			str = "gelu"     ,       lowercase		:			float = 0.05     ,       lowercase		:			float = 0.1     ,       lowercase		:			float = 0.1     ,       lowercase		:			float = 0.1     ,       lowercase		:			float = 0.1     ,       lowercase		:			int = 100     ,       lowercase		:			float = 0.02     ,       lowercase		:			str=True     ,       lowercase		:			str = "prob"     ,       lowercase		:			int = 5     ,       lowercase		:			bool = True     ,       **lowercase		:			Optional[Any]     ,       ):



           '''simple docstring'''

           UpperCAmelCase     =	prediction_length
           UpperCAmelCase     =	context_length or prediction_length
           UpperCAmelCase     =	distribution_output
           UpperCAmelCase     =	loss
           UpperCAmelCase     =	input_size
           UpperCAmelCase     =	num_time_features
           UpperCAmelCase     =	lags_sequence if lags_sequence is not None else [1, 2, 3, 4, 5, 6, 7]
           UpperCAmelCase     =	scaling
           UpperCAmelCase     =	num_dynamic_real_features
           UpperCAmelCase     =	num_static_real_features
           UpperCAmelCase     =	num_static_categorical_features

           # set cardinality
           if cardinality and num_static_categorical_features > 0:
               if len(lowercase       ) != 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]

           # set embedding_dimension
           if embedding_dimension and num_static_categorical_features > 0:
               if len(lowercase       ) != 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

           # Informer
           UpperCAmelCase     =	attention_type
           UpperCAmelCase     =	sampling_factor
           UpperCAmelCase     =	distil

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







       @property
       def 					A   (			self		:			Dict       ):



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










'''simple docstring'''







import json
import os
import unittest

from transformers import MgpstrTokenizer
from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin


@require_tokenizers
class     _a						(			__a							,							unittest.TestCase				):
       __a       :  Any            =      MgpstrTokenizer
       __a       :  Optional[Any]            =      False
       __a       :  str            =      {}
       __a       :  Optional[int]            =      False
       def 					A   (			self		:			Dict       ):



           '''simple docstring'''

           super().setUp()

           # fmt: off
           UpperCAmelCase     =	['''[GO]''', '''[s]''', '''0''', '''1''', '''2''', '''3''', '''4''', '''5''', '''6''', '''7''', '''8''', '''9''', '''a''', '''b''', '''c''', '''d''', '''e''', '''f''', '''g''', '''h''', '''i''', '''j''', '''k''', '''l''', '''m''', '''n''', '''o''', '''p''', '''q''', '''r''', '''s''', '''t''', '''u''', '''v''', '''w''', '''x''', '''y''', '''z''']
           # fmt: on
           UpperCAmelCase     =	dict(zip(lowercase     ,       range(len(lowercase       )       )       )       )

           UpperCAmelCase     =	os.path.join(self.tmpdirname     ,       VOCAB_FILES_NAMES['''vocab_file''']       )
           with open(self.vocab_file     ,       '''w'''     ,       encoding='''utf-8'''       ) as fp:
               fp.write(json.dumps(lowercase       ) + '''\n'''       )
       def 					A   (			self		:			int     ,       **lowercase		:			Optional[Any]       ):



           '''simple docstring'''

           return MgpstrTokenizer.from_pretrained(self.tmpdirname     ,       **lowercase       )
       def 					A   (			self		:			int     ,       lowercase		:			str       ):



           '''simple docstring'''

           UpperCAmelCase     =	'''tester'''
           UpperCAmelCase     =	'''tester'''
           return input_text, output_text
       @unittest.skip('''MGP-STR always lower cases letters.'''       )
       def 					A   (			self		:			Optional[int]       ):



           '''simple docstring'''

           pass
       def 					A   (			self		:			int       ):



           '''simple docstring'''

           UpperCAmelCase     =	self.get_tokenizers(do_lower_case=lowercase       )
           for tokenizer in tokenizers:
               with self.subTest(f"{tokenizer.__class__.__name__}"       ):
                   UpperCAmelCase     =	'''[SPECIAL_TOKEN]'''

                   tokenizer.add_special_tokens({'''cls_token''': special_token}       )
                   UpperCAmelCase     =	tokenizer.encode([special_token]     ,       add_special_tokens=lowercase       )
                   self.assertEqual(len(lowercase       )     ,       1       )

                   UpperCAmelCase     =	tokenizer.decode(lowercase     ,       skip_special_tokens=lowercase       )
                   self.assertTrue(special_token not in decoded       )
       def 					A   (			self		:			List[Any]       ):



           '''simple docstring'''

           UpperCAmelCase     =	self.get_tokenizers()
           for tokenizer in tokenizers:
               with self.subTest(f"{tokenizer.__class__.__name__}"       ):
                   UpperCAmelCase ,  UpperCAmelCase     =	self.get_input_output_texts(lowercase       )

                   UpperCAmelCase     =	tokenizer.tokenize(lowercase       )
                   UpperCAmelCase     =	tokenizer.convert_tokens_to_ids(lowercase       )
                   UpperCAmelCase     =	tokenizer.encode(lowercase     ,       add_special_tokens=lowercase       )
                   self.assertListEqual(lowercase     ,       lowercase       )

                   UpperCAmelCase     =	tokenizer.convert_ids_to_tokens(lowercase       )
                   self.assertNotEqual(len(lowercase       )     ,       0       )
                   UpperCAmelCase     =	tokenizer.decode(lowercase       )
                   self.assertIsInstance(lowercase     ,       lowercase       )

                   self.assertEqual(text_a.replace(''' '''     ,       ''''''       )     ,       lowercase       )
       @unittest.skip('''MGP-STR tokenizer only handles one sequence.'''       )
       def 					A   (			self		:			Any       ):



           '''simple docstring'''

           pass







       @unittest.skip('''inputs cannot be pretokenized in MgpstrTokenizer'''       )
       def 					A   (			self		:			str       ):



           '''simple docstring'''

           pass




