
from typing import List, Optional, Union

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


lowercase_ 				=			logging.get_logger(__name__)

lowercase_ 				=			{
    """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     __UpperCamelCase (							lowerCAmelCase__       ):






     """simple docstring"""







     lowerCAmelCase_							   =			'''informer'''
     lowerCAmelCase_							   =			{
         '''hidden_size''': '''d_model''',
         '''num_attention_heads''': '''encoder_attention_heads''',
         '''num_hidden_layers''': '''encoder_layers''',
     }



     def __init__(				self							:							Tuple     ,						_A							:							Optional[int] = None     ,						_A							:							Optional[int] = None     ,						_A							:							str = "student_t"     ,						_A							:							str = "nll"     ,						_A							:							int = 1     ,						_A							:							List[int] = None     ,						_A							:							Optional[Union[str, bool]] = "mean"     ,						_A							:							int = 0     ,						_A							:							int = 0     ,						_A							:							int = 0     ,						_A							:							int = 0     ,						_A							:							Optional[List[int]] = None     ,						_A							:							Optional[List[int]] = None     ,						_A							:							int = 64     ,						_A							:							int = 32     ,						_A							:							int = 32     ,						_A							:							int = 2     ,						_A							:							int = 2     ,						_A							:							int = 2     ,						_A							:							int = 2     ,						_A							:							bool = True     ,						_A							:							str = "gelu"     ,						_A							:							float = 0.05     ,						_A							:							float = 0.1     ,						_A							:							float = 0.1     ,						_A							:							float = 0.1     ,						_A							:							float = 0.1     ,						_A							:							int = 100     ,						_A							:							float = 0.02     ,						_A							:							Union[str, Any]=True     ,						_A							:							str = "prob"     ,						_A							:							int = 5     ,						_A							:							bool = True     ,						**_A							:							int     ,						):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Any					=		prediction_length
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		context_length or prediction_length
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		distribution_output
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		loss
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		input_size
       __SCREAMING_SNAKE_CASE      :	Any					=		num_time_features
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		lags_sequence if lags_sequence is not None else [1, 2, 3, 4, 5, 6, 7]
       __SCREAMING_SNAKE_CASE      :	Tuple					=		scaling
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		num_dynamic_real_features
       __SCREAMING_SNAKE_CASE      :	str					=		num_static_real_features
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		num_static_categorical_features

       # set cardinality
       if cardinality 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`''' )
         __SCREAMING_SNAKE_CASE      :	List[Any]					=		cardinality
       else:
         __SCREAMING_SNAKE_CASE      :	int					=		[0]

       # set embedding_dimension
       if embedding_dimension 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`''' )
         __SCREAMING_SNAKE_CASE      :	Any					=		embedding_dimension
       else:
         __SCREAMING_SNAKE_CASE      :	Optional[int]					=		[min(50     ,						(cat + 1) // 2 ) for cat in self.cardinality]

       __SCREAMING_SNAKE_CASE      :	str					=		num_parallel_samples

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

       __SCREAMING_SNAKE_CASE      :	List[str]					=		dropout
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		attention_dropout
       __SCREAMING_SNAKE_CASE      :	Any					=		activation_dropout
       __SCREAMING_SNAKE_CASE      :	int					=		encoder_layerdrop
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		decoder_layerdrop

       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		activation_function
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		init_std

       __SCREAMING_SNAKE_CASE      :	List[str]					=		use_cache

       # Informer
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		attention_type
       __SCREAMING_SNAKE_CASE      :	int					=		sampling_factor
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		distil

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




     @property
     def  UpperCAmelCase__							(				self							:							Optional[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 warnings
from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType



class 				_UpperCamelCase      (a_      ):
      snake_case_	=				["""image_processor""", """tokenizer"""]
      snake_case_	=				"""FlavaImageProcessor"""
      snake_case_	=				("""BertTokenizer""", """BertTokenizerFast""")


      def __init__(						self       ,    __UpperCamelCase=None       ,    __UpperCamelCase=None       ,    **__UpperCamelCase						)->						Tuple:
           __lowerCAmelCase             =       None
           if "feature_extractor" in kwargs:
                warnings.warn(
                    "The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"
                    " instead."       ,    __UpperCamelCase       ,    )
                __lowerCAmelCase             =       kwargs.pop("feature_extractor"						)

           __lowerCAmelCase             =       image_processor if image_processor is not None else feature_extractor
           if image_processor is None:
                raise ValueError("You need to specify an `image_processor`."						)
           if tokenizer is None:
                raise ValueError("You need to specify a `tokenizer`."						)

           super().__init__(__UpperCamelCase       ,    __UpperCamelCase						)
           __lowerCAmelCase             =       self.image_processor


      def __call__(						self       ,    __UpperCamelCase = None       ,    __UpperCamelCase = None       ,    __UpperCamelCase = True       ,    __UpperCamelCase = False       ,    __UpperCamelCase = False       ,    __UpperCamelCase = None       ,    __UpperCamelCase = 0       ,    __UpperCamelCase = None       ,    __UpperCamelCase = None       ,    __UpperCamelCase = None       ,    __UpperCamelCase = None       ,    __UpperCamelCase = None       ,    __UpperCamelCase = False       ,    __UpperCamelCase = False       ,    __UpperCamelCase = False       ,    __UpperCamelCase = False       ,    __UpperCamelCase = True       ,    __UpperCamelCase = None       ,    **__UpperCamelCase       ,    )->						int:

           if text is None and images is None:
                raise ValueError("You have to specify either text or images. Both cannot be none."						)

           if text is not None:
                __lowerCAmelCase             =       self.tokenizer(
                    text=__UpperCamelCase       ,    add_special_tokens=__UpperCamelCase       ,    padding=__UpperCamelCase       ,    truncation=__UpperCamelCase       ,    max_length=__UpperCamelCase       ,    stride=__UpperCamelCase       ,    pad_to_multiple_of=__UpperCamelCase       ,    return_token_type_ids=__UpperCamelCase       ,    return_attention_mask=__UpperCamelCase       ,    return_overflowing_tokens=__UpperCamelCase       ,    return_special_tokens_mask=__UpperCamelCase       ,    return_offsets_mapping=__UpperCamelCase       ,    return_length=__UpperCamelCase       ,    verbose=__UpperCamelCase       ,    return_tensors=__UpperCamelCase       ,    **__UpperCamelCase       ,    )
           if images is not None:
                __lowerCAmelCase             =       self.image_processor(
                    __UpperCamelCase       ,    return_image_mask=__UpperCamelCase       ,    return_codebook_pixels=__UpperCamelCase       ,    return_tensors=__UpperCamelCase       ,    **__UpperCamelCase       ,    )

           if text is not None and images is not None:
                encoding.update(__UpperCamelCase						)
                return encoding
           elif text is not None:
                return encoding
           else:
                return BatchEncoding(data=dict(**__UpperCamelCase						)       ,    tensor_type=__UpperCamelCase						)


      def 			__UpperCAmelCase		(						self       ,    *__UpperCamelCase       ,    **__UpperCamelCase						)->						int:
           return self.tokenizer.batch_decode(*__UpperCamelCase       ,    **__UpperCamelCase						)


      def 			__UpperCAmelCase		(						self       ,    *__UpperCamelCase       ,    **__UpperCamelCase						)->						Optional[int]:
           return self.tokenizer.decode(*__UpperCamelCase       ,    **__UpperCamelCase						)


      @property
      def 			__UpperCAmelCase		(						self						)->						Any:
           __lowerCAmelCase             =       self.tokenizer.model_input_names
           __lowerCAmelCase             =       self.image_processor.model_input_names
           return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names						)						)


      @property
      def 			__UpperCAmelCase		(						self						)->						Dict:
           warnings.warn(
               "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."       ,    __UpperCamelCase       ,    )
           return self.image_processor_class


      @property
      def 			__UpperCAmelCase		(						self						)->						Union[str, Any]:
           warnings.warn(
               "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."       ,    __UpperCamelCase       ,    )
           return self.image_processor






