





import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
from ...utils import logging
from ..auto import CONFIG_MAPPING


SCREAMING_SNAKE_CASE__       :			Optional[Any]			      =						logging.get_logger(__name__)

SCREAMING_SNAKE_CASE__       :			Any			      =						{
    """Salesforce/instruct-blip-flan-t5""": """https://huggingface.co/Salesforce/instruct-blip-flan-t5/resolve/main/config.json""",
}







class   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						List[Any]     		=				"""instructblip_vision_model"""





   def __init__( self					,			snake_case=1_408					,			snake_case=6_144					,			snake_case=39					,			snake_case=16					,			snake_case=224					,			snake_case=14					,			snake_case="gelu"					,			snake_case=1E-6					,			snake_case=0.0					,			snake_case=1E-10					,			snake_case=True					,			**snake_case					,			)				->  Optional[Any]:
      """simple docstring"""





      super().__init__(**snake_case      )

      a__	:						Dict      		=  hidden_size
      a__	:						Tuple      		=  intermediate_size
      a__	:						Dict      		=  num_hidden_layers
      a__	:						Optional[int]      		=  num_attention_heads
      a__	:						Optional[Any]      		=  patch_size
      a__	:						Union[str, Any]      		=  image_size
      a__	:						Optional[int]      		=  initializer_range
      a__	:						int      		=  attention_dropout
      a__	:						List[str]      		=  layer_norm_eps
      a__	:						List[Any]      		=  hidden_act
      a__	:						Tuple      		=  qkv_bias





   @classmethod
   def 	_snake_case ( cls					,			snake_case					,			**snake_case      )				->  "PretrainedConfig":
      """simple docstring"""





      cls._set_token_in_kwargs(snake_case      )

      a__		,     a__	:						Tuple      		=  cls.get_config_dict(snake_case					,			**snake_case      )

      # get the vision config dict if we are loading from InstructBlipConfig
      if config_dict.get("model_type"      ) == "instructblip":
         a__	:						Optional[Any]      		=  config_dict["vision_config"]

      if "model_type" in config_dict and hasattr(cls					,			"model_type"      ) and config_dict["model_type"] != cls.model_type:
         logger.warning(
             F"""You are using a model of type {config_dict["model_type"]} to instantiate a model of type """
             F"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""      )

      return cls.from_dict(snake_case					,			**snake_case      )







class   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						List[Any]     		=				"""instructblip_qformer"""





   def __init__( self					,			snake_case=30_522					,			snake_case=768					,			snake_case=12					,			snake_case=12					,			snake_case=3_072					,			snake_case="gelu"					,			snake_case=0.1					,			snake_case=0.1					,			snake_case=512					,			snake_case=0.02					,			snake_case=1E-12					,			snake_case=0					,			snake_case="absolute"					,			snake_case=2					,			snake_case=1_408					,			**snake_case					,			)				->  List[str]:
      """simple docstring"""





      super().__init__(pad_token_id=snake_case					,			**snake_case      )

      a__	:						List[str]      		=  vocab_size
      a__	:						Tuple      		=  hidden_size
      a__	:						List[str]      		=  num_hidden_layers
      a__	:						Union[str, Any]      		=  num_attention_heads
      a__	:						Tuple      		=  hidden_act
      a__	:						Dict      		=  intermediate_size
      a__	:						Any      		=  hidden_dropout_prob
      a__	:						int      		=  attention_probs_dropout_prob
      a__	:						Optional[Any]      		=  max_position_embeddings
      a__	:						List[str]      		=  initializer_range
      a__	:						Optional[int]      		=  layer_norm_eps
      a__	:						Tuple      		=  position_embedding_type
      a__	:						str      		=  cross_attention_frequency
      a__	:						List[str]      		=  encoder_hidden_size





   @classmethod
   def 	_snake_case ( cls					,			snake_case					,			**snake_case      )				->  "PretrainedConfig":
      """simple docstring"""





      cls._set_token_in_kwargs(snake_case      )

      a__		,     a__	:						Optional[int]      		=  cls.get_config_dict(snake_case					,			**snake_case      )

      # get the qformer config dict if we are loading from InstructBlipConfig
      if config_dict.get("model_type"      ) == "instructblip":
         a__	:						Tuple      		=  config_dict["qformer_config"]

      if "model_type" in config_dict and hasattr(cls					,			"model_type"      ) and config_dict["model_type"] != cls.model_type:
         logger.warning(
             F"""You are using a model of type {config_dict["model_type"]} to instantiate a model of type """
             F"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""      )

      return cls.from_dict(snake_case					,			**snake_case      )







class   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						List[str]     		=				"""instructblip"""
   _UpperCamelCase :						Optional[Any]     		=				True





   def __init__( self					,			snake_case=None					,			snake_case=None					,			snake_case=None					,			snake_case=32					,			**snake_case      )				->  str:
      """simple docstring"""





      super().__init__(**snake_case      )

      if vision_config is None:
         a__	:						List[Any]      		=  {}
         logger.info("vision_config is None. initializing the InstructBlipVisionConfig with default values."      )

      if qformer_config is None:
         a__	:						List[Any]      		=  {}
         logger.info("qformer_config is None. Initializing the InstructBlipQFormerConfig with default values."      )

      if text_config is None:
         a__	:						List[Any]      		=  {}
         logger.info("text_config is None. Initializing the text config with default values (`OPTConfig`)."      )

      a__	:						Union[str, Any]      		=  InstructBlipVisionConfig(**snake_case      )
      a__	:						Union[str, Any]      		=  InstructBlipQFormerConfig(**snake_case      )
      a__	:						Optional[Any]      		=  text_config["model_type"] if "model_type" in text_config else "opt"
      a__	:						Tuple      		=  CONFIG_MAPPING[text_model_type](**snake_case      )

      a__	:						int      		=  self.text_config.tie_word_embeddings
      a__	:						Union[str, Any]      		=  self.text_config.is_encoder_decoder

      a__	:						List[str]      		=  num_query_tokens
      a__	:						List[str]      		=  self.vision_config.hidden_size
      a__	:						List[Any]      		=  self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
      a__	:						Union[str, Any]      		=  1.0
      a__	:						str      		=  0.02





   @classmethod
   def 	_snake_case ( cls					,			snake_case					,			snake_case					,			snake_case					,			**snake_case					,			)				->  Union[str, Any]:
      """simple docstring"""





      return cls(
          vision_config=vision_config.to_dict()					,			qformer_config=qformer_config.to_dict()					,			text_config=text_config.to_dict()					,			**snake_case					,			)





   def 	_snake_case ( self      )				->  List[str]:
      """simple docstring"""





      a__	:						int      		=  copy.deepcopy(self.__dict__      )
      a__	:						Union[str, Any]      		=  self.vision_config.to_dict()
      a__	:						Dict      		=  self.qformer_config.to_dict()
      a__	:						Dict      		=  self.text_config.to_dict()
      a__	:						Optional[Any]      		=  self.__class__.model_type
      return output








from typing import List, Optional, Union

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


SCREAMING_SNAKE_CASE__       :			Any			      =						logging.get_logger(__name__)

SCREAMING_SNAKE_CASE__       :			str			      =						{
    """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   __lowerCAmelCase			(					_UpperCamelCase  ):
   _UpperCamelCase :						Optional[Any]     		=				"""informer"""
   _UpperCamelCase :						Any     		=				{
       """hidden_size""": """d_model""",
       """num_attention_heads""": """encoder_attention_heads""",
       """num_hidden_layers""": """encoder_layers""",
   }





   def __init__( self					,			snake_case = None					,			snake_case = None					,			snake_case = "student_t"					,			snake_case = "nll"					,			snake_case = 1					,			snake_case = None					,			snake_case = "mean"					,			snake_case = 0					,			snake_case = 0					,			snake_case = 0					,			snake_case = 0					,			snake_case = None					,			snake_case = None					,			snake_case = 64					,			snake_case = 32					,			snake_case = 32					,			snake_case = 2					,			snake_case = 2					,			snake_case = 2					,			snake_case = 2					,			snake_case = True					,			snake_case = "gelu"					,			snake_case = 0.05					,			snake_case = 0.1					,			snake_case = 0.1					,			snake_case = 0.1					,			snake_case = 0.1					,			snake_case = 100					,			snake_case = 0.02					,			snake_case=True					,			snake_case = "prob"					,			snake_case = 5					,			snake_case = True					,			**snake_case					,			)				->  Union[str, Any]:
      """simple docstring"""





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

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

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

      a__	:						Optional[Any]      		=  num_parallel_samples

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

      a__	:						List[str]      		=  dropout
      a__	:						int      		=  attention_dropout
      a__	:						List[Any]      		=  activation_dropout
      a__	:						Optional[int]      		=  encoder_layerdrop
      a__	:						Tuple      		=  decoder_layerdrop

      a__	:						Any      		=  activation_function
      a__	:						Tuple      		=  init_std

      a__	:						Optional[int]      		=  use_cache

      # Informer
      a__	:						Union[str, Any]      		=  attention_type
      a__	:						List[str]      		=  sampling_factor
      a__	:						Optional[int]      		=  distil

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





   @property
   def 	_snake_case ( self      )				->  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
      )

