





'''simple docstring'''


from typing import List, Optional, Union

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


lowerCAmelCase_ : str	  =       logging.get_logger(__name__)

lowerCAmelCase_ : List[str]	  =       {
    "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__	(		lowerCAmelCase__  ):
	lowerCAmelCase__       :      Any										=    "time_series_transformer"
	lowerCAmelCase__       :      int										=    {
	    "hidden_size": "d_model",
	    "num_attention_heads": "encoder_attention_heads",
	    "num_hidden_layers": "encoder_layers",
	}







	def __init__(					self      : Any			,			lowerCamelCase      : Optional[Any] = None			,			lowerCamelCase      : Optional[Any] = None			,			lowerCamelCase      : Optional[int] = "student_t"			,			lowerCamelCase      : Union[str, Any] = "nll"			,			lowerCamelCase      : List[str] = 1			,			lowerCamelCase      : Optional[Any] = [1, 2, 3, 4, 5, 6, 7]			,			lowerCamelCase      : str = "mean"			,			lowerCamelCase      : Union[str, Any] = 0			,			lowerCamelCase      : int = 0			,			lowerCamelCase      : int = 0			,			lowerCamelCase      : Optional[int] = 0			,			lowerCamelCase      : Tuple = None			,			lowerCamelCase      : List[Any] = None			,			lowerCamelCase      : Tuple = 3_2			,			lowerCamelCase      : Optional[Any] = 3_2			,			lowerCamelCase      : List[Any] = 2			,			lowerCamelCase      : Union[str, Any] = 2			,			lowerCamelCase      : Any = 2			,			lowerCamelCase      : Any = 2			,			lowerCamelCase      : str = True			,			lowerCamelCase      : Optional[Any] = "gelu"			,			lowerCamelCase      : Any = 6_4			,			lowerCamelCase      : List[Any] = 0.1			,			lowerCamelCase      : Any = 0.1			,			lowerCamelCase      : Union[str, Any] = 0.1			,			lowerCamelCase      : List[str] = 0.1			,			lowerCamelCase      : Optional[Any] = 0.1			,			lowerCamelCase      : List[Any] = 1_0_0			,			lowerCamelCase      : List[Any] = 0.02			,			lowerCamelCase      : str=True			,			**lowerCamelCase      : Any			,			):




				'''simple docstring'''
				a__	 =			prediction_length
				a__	 =			context_length or prediction_length
				a__	 =			distribution_output
				a__	 =			loss
				a__	 =			input_size
				a__	 =			num_time_features
				a__	 =			lags_sequence
				a__	 =			scaling
				a__	 =			num_dynamic_real_features
				a__	 =			num_static_real_features
				a__	 =			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`"		)
							a__	 =			cardinality
				else:
							a__	 =			[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`"		)
							a__	 =			embedding_dimension
				else:
							a__	 =			[min(5_0			,			(cat + 1) // 2		) for cat in self.cardinality]
				a__	 =			num_parallel_samples

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

				a__	 =			dropout
				a__	 =			attention_dropout
				a__	 =			activation_dropout
				a__	 =			encoder_layerdrop
				a__	 =			decoder_layerdrop

				a__	 =			activation_function
				a__	 =			init_std

				a__	 =			use_cache

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







	@property
	def     __a (					self      : List[Any]		):




				'''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 os
import sys
import unittest


a_								=       os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, """utils"""))

import check_dummies  # noqa: E402
from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init  # noqa: E402


# Align TRANSFORMERS_PATH in check_dummies with the current path
a_								=       os.path.join(git_repo_path, """src""", """transformers""")

a_								=       """
{0} = None
"""

a_								=       """
class {0}(metaclass=DummyObject):
    _backends = {1}

    def __init__(self, *args, **kwargs):
        requires_backends(self, {1})
"""


a_								=       """
def {0}(*args, **kwargs):
    requires_backends({0}, {1})
"""



class 			__lowerCAmelCase  (						unittest.TestCase ):




 def 							lowerCamelCase   (    self					):



    '''simple docstring'''
    __lowerCamelCase    				=     find_backend('''    _import_structure["models.albert"].append("AlbertTokenizerFast")'''					)
    self.assertIsNone(__UpperCAmelCase					)

    __lowerCamelCase    				=     find_backend('''    if not is_tokenizers_available():'''					)
    self.assertEqual(__UpperCAmelCase						,					'''tokenizers'''					)

    __lowerCamelCase    				=     find_backend('''    if not is_tensorflow_text_available():'''					)
    self.assertEqual(__UpperCAmelCase						,					'''tensorflow_text'''					)

    __lowerCamelCase    				=     find_backend('''    if not (is_sentencepiece_available() and is_tokenizers_available()):'''					)
    self.assertEqual(__UpperCAmelCase						,					'''sentencepiece_and_tokenizers'''					)

    __lowerCamelCase    				=     find_backend(
        '''    if not (is_sentencepiece_available() and is_tensorflow_text_available()):'''					)
    self.assertEqual(__UpperCAmelCase						,					'''sentencepiece_and_tensorflow_text'''					)

    __lowerCamelCase    				=     find_backend(
        '''    if not (is_sentencepiece_available() and is_tokenizers_available() and is_vision_available()):'''					)
    self.assertEqual(__UpperCAmelCase						,					'''sentencepiece_and_tokenizers_and_vision'''					)




 def 							lowerCamelCase   (    self					):



    '''simple docstring'''
    __lowerCamelCase    				=     read_init()
    # We don't assert on the exact list of keys to allow for smooth grow of backend-specific objects
    self.assertIn('''torch'''						,					__UpperCAmelCase					)
    self.assertIn('''tensorflow_text'''						,					__UpperCAmelCase					)
    self.assertIn('''sentencepiece_and_tokenizers'''						,					__UpperCAmelCase					)

    # Likewise, we can't assert on the exact content of a key
    self.assertIn('''BertModel'''						,					objects['''torch''']					)
    self.assertIn('''TFBertModel'''						,					objects['''tf''']					)
    self.assertIn('''FlaxBertModel'''						,					objects['''flax''']					)
    self.assertIn('''BertModel'''						,					objects['''torch''']					)
    self.assertIn('''TFBertTokenizer'''						,					objects['''tensorflow_text''']					)
    self.assertIn('''convert_slow_tokenizer'''						,					objects['''sentencepiece_and_tokenizers''']					)




 def 							lowerCamelCase   (    self					):



    '''simple docstring'''
    __lowerCamelCase    				=     create_dummy_object('''CONSTANT'''						,					'''\'torch\''''					)
    self.assertEqual(__UpperCAmelCase						,					'''\nCONSTANT = None\n'''					)

    __lowerCamelCase    				=     create_dummy_object('''function'''						,					'''\'torch\''''					)
    self.assertEqual(
        __UpperCAmelCase						,					'''\ndef function(*args, **kwargs):\n    requires_backends(function, \'torch\')\n'''					)

    __lowerCamelCase    				=     '''
class FakeClass(metaclass=DummyObject):
    _backends = \'torch\'

    def __init__(self, *args, **kwargs):
        requires_backends(self, \'torch\')
'''
    __lowerCamelCase    				=     create_dummy_object('''FakeClass'''						,					'''\'torch\''''					)
    self.assertEqual(__UpperCAmelCase						,					__UpperCAmelCase					)




 def 							lowerCamelCase   (    self					):



    '''simple docstring'''
    __lowerCamelCase    				=     '''# This file is autogenerated by the command `make fix-copies`, do not edit.
from ..utils import DummyObject, requires_backends


CONSTANT = None


def function(*args, **kwargs):
    requires_backends(function, ["torch"])


class FakeClass(metaclass=DummyObject):
    _backends = ["torch"]

    def __init__(self, *args, **kwargs):
        requires_backends(self, ["torch"])
'''
    __lowerCamelCase    				=     create_dummy_files({'''torch''': ['''CONSTANT''', '''function''', '''FakeClass''']}					)
    self.assertEqual(dummy_files['''torch''']						,					__UpperCAmelCase					)






