


from typing import List, Optional

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


A	:		Union[str, Any]    =       logging.get_logger(__name__)

A	:		int    =       {
    'huggingface/autoformer-tourism-monthly': 'https://huggingface.co/huggingface/autoformer-tourism-monthly/resolve/main/config.json',
}



class 							A   (	UpperCAmelCase__							):
     '''simple docstring'''






     A__      =			'''autoformer'''
     A__      =			{
         '''hidden_size''': '''d_model''',
         '''num_attention_heads''': '''encoder_attention_heads''',
         '''num_hidden_layers''': '''encoder_layers''',
     }

     def __init__(self   :						Any				, _UpperCAmelCase   :						List[Any] = None				, _UpperCAmelCase   :						List[Any] = None				, _UpperCAmelCase   :						Optional[int] = "student_t"				, _UpperCAmelCase   :						List[str] = "nll"				, _UpperCAmelCase   :						Optional[int] = 1				, _UpperCAmelCase   :						List[str] = [1, 2, 3, 4, 5, 6, 7]				, _UpperCAmelCase   :						Optional[Any] = True				, _UpperCAmelCase   :						Optional[int] = 0				, _UpperCAmelCase   :						int = 0				, _UpperCAmelCase   :						str = 0				, _UpperCAmelCase   :						str = 0				, _UpperCAmelCase   :						Dict = None				, _UpperCAmelCase   :						Any = None				, _UpperCAmelCase   :						Tuple = 64				, _UpperCAmelCase   :						int = 2				, _UpperCAmelCase   :						Union[str, Any] = 2				, _UpperCAmelCase   :						int = 2				, _UpperCAmelCase   :						str = 2				, _UpperCAmelCase   :						int = 32				, _UpperCAmelCase   :						Optional[Any] = 32				, _UpperCAmelCase   :						Optional[Any] = "gelu"				, _UpperCAmelCase   :						Optional[int] = 0.1				, _UpperCAmelCase   :						List[Any] = 0.1				, _UpperCAmelCase   :						List[Any] = 0.1				, _UpperCAmelCase   :						int = 0.1				, _UpperCAmelCase   :						Optional[int] = 0.1				, _UpperCAmelCase   :						str = 100				, _UpperCAmelCase   :						List[Any] = 0.02				, _UpperCAmelCase   :						Optional[int] = True				, _UpperCAmelCase   :						Union[str, Any]=True				, _UpperCAmelCase   :						List[str] = 10				, _UpperCAmelCase   :						Optional[Any] = 25				, _UpperCAmelCase   :						Any = 3				, **_UpperCAmelCase   :						Optional[Any]				, )						->       str:




       """simple docstring"""


       lowercase__					      =		prediction_length
       lowercase__					      =		context_length if context_length is not None else prediction_length
       lowercase__					      =		distribution_output
       lowercase__					      =		loss
       lowercase__					      =		input_size
       lowercase__					      =		num_time_features
       lowercase__					      =		lags_sequence
       lowercase__					      =		scaling
       lowercase__					      =		num_dynamic_real_features
       lowercase__					      =		num_static_real_features
       lowercase__					      =		num_static_categorical_features
       if cardinality is not None and num_static_categorical_features > 0:
         if len(_SCREAMING_SNAKE_CASE		) != num_static_categorical_features:
           raise ValueError(
               """The cardinality should be a list of the same length as `num_static_categorical_features`"""		)
         lowercase__					      =		cardinality
       else:
         lowercase__					      =		[0]
       if embedding_dimension is not None and num_static_categorical_features > 0:
         if len(_SCREAMING_SNAKE_CASE		) != num_static_categorical_features:
           raise ValueError(
               """The embedding dimension should be a list of the same length as `num_static_categorical_features`"""		)
         lowercase__					      =		embedding_dimension
       else:
         lowercase__					      =		[min(50				, (cat + 1) // 2		) for cat in self.cardinality]
       lowercase__					      =		num_parallel_samples

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

       lowercase__					      =		dropout
       lowercase__					      =		attention_dropout
       lowercase__					      =		activation_dropout
       lowercase__					      =		encoder_layerdrop
       lowercase__					      =		decoder_layerdrop

       lowercase__					      =		activation_function
       lowercase__					      =		init_std

       lowercase__					      =		use_cache

       # Autoformer
       lowercase__					      =		label_length
       lowercase__					      =		moving_average
       lowercase__					      =		autocorrelation_factor

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


     @property
     def   lowerCamelCase__					(self   :						Optional[Any]		)						->       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 json
import os
import unittest

from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast
from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES
from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin



@require_tokenizers
class 							A   (	UpperCAmelCase__			,  unittest.TestCase							):
					'''simple docstring'''






					A__      =			OpenAIGPTTokenizer
					A__      =			OpenAIGPTTokenizerFast
					A__      =			True
					A__      =			False

					def   lowerCamelCase__					(self   :						List[str]		)						->       int:




							"""simple docstring"""


							super().setUp()

							# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
							lowercase__					      =		[
							    """l""",
							    """o""",
							    """w""",
							    """e""",
							    """r""",
							    """s""",
							    """t""",
							    """i""",
							    """d""",
							    """n""",
							    """w</w>""",
							    """r</w>""",
							    """t</w>""",
							    """lo""",
							    """low""",
							    """er</w>""",
							    """low</w>""",
							    """lowest</w>""",
							    """newer</w>""",
							    """wider</w>""",
							    """<unk>""",
							]
							lowercase__					      =		dict(zip(_UpperCAmelCase				, range(len(_UpperCAmelCase		)		)		)		)
							lowercase__					      =		["""#version: 0.2""", """l o""", """lo w""", """e r</w>""", """"""]

							lowercase__					      =		os.path.join(self.tmpdirname				, VOCAB_FILES_NAMES["""vocab_file"""]		)
							lowercase__					      =		os.path.join(self.tmpdirname				, VOCAB_FILES_NAMES["""merges_file"""]		)
							with open(self.vocab_file				, """w"""		) as fp:
									fp.write(json.dumps(_UpperCAmelCase		)		)
							with open(self.merges_file				, """w"""		) as fp:
									fp.write("""\n""".join(_UpperCAmelCase		)		)

					def   lowerCamelCase__					(self   :						Dict				, _UpperCAmelCase   :						List[Any]		)						->       Any:




							"""simple docstring"""


							return "lower newer", "lower newer"

					def   lowerCamelCase__					(self   :						Dict		)						->       Tuple:




							"""simple docstring"""


							lowercase__					      =		OpenAIGPTTokenizer(self.vocab_file				, self.merges_file		)

							lowercase__					      =		"""lower"""
							lowercase__					      =		["""low""", """er</w>"""]
							lowercase__					      =		tokenizer.tokenize(_UpperCAmelCase		)
							self.assertListEqual(_UpperCAmelCase				, _UpperCAmelCase		)

							lowercase__					      =		tokens + ["""<unk>"""]
							lowercase__					      =		[14, 15, 20]
							self.assertListEqual(tokenizer.convert_tokens_to_ids(_UpperCAmelCase		)				, _UpperCAmelCase		)

					def   lowerCamelCase__					(self   :						Optional[int]				, _UpperCAmelCase   :						Union[str, Any]=15		)						->       Optional[int]:




							"""simple docstring"""


							for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
									with self.subTest(f'''{tokenizer.__class__.__name__} ({pretrained_name})'''		):
											lowercase__					      =		self.rust_tokenizer_class.from_pretrained(_UpperCAmelCase				, **_UpperCAmelCase		)

											# Simple input
											lowercase__					      =		"""This is a simple input"""
											lowercase__					      =		["""This is a simple input 1""", """This is a simple input 2"""]
											lowercase__					      =		("""This is a simple input""", """This is a pair""")
											lowercase__					      =		[
											    ("""This is a simple input 1""", """This is a simple input 2"""),
											    ("""This is a simple pair 1""", """This is a simple pair 2"""),
											]

											# Simple input tests
											self.assertRaises(_UpperCAmelCase				, tokenizer_r.encode				, _UpperCAmelCase				, max_length=_UpperCAmelCase				, padding="""max_length"""		)

											# Simple input
											self.assertRaises(_UpperCAmelCase				, tokenizer_r.encode_plus				, _UpperCAmelCase				, max_length=_UpperCAmelCase				, padding="""max_length"""		)

											# Simple input
											self.assertRaises(
											    _UpperCAmelCase				, tokenizer_r.batch_encode_plus				, _UpperCAmelCase				, max_length=_UpperCAmelCase				, padding="""max_length"""				, )

											# Pair input
											self.assertRaises(_UpperCAmelCase				, tokenizer_r.encode				, _UpperCAmelCase				, max_length=_UpperCAmelCase				, padding="""max_length"""		)

											# Pair input
											self.assertRaises(_UpperCAmelCase				, tokenizer_r.encode_plus				, _UpperCAmelCase				, max_length=_UpperCAmelCase				, padding="""max_length"""		)

											# Pair input
											self.assertRaises(
											    _UpperCAmelCase				, tokenizer_r.batch_encode_plus				, _UpperCAmelCase				, max_length=_UpperCAmelCase				, padding="""max_length"""				, )


					def   lowerCamelCase__					(self   :						Tuple		)						->       Any:




							"""simple docstring"""


							pass






@require_ftfy
@require_spacy
@require_tokenizers
class 							A   (	UpperCAmelCase__							):
					'''simple docstring'''






					pass

