


'''simple docstring'''






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


__A					:  List[Any]											=      logging.get_logger(__name__)

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






class    __snake_case       (   _SCREAMING_SNAKE_CASE):







    """simple docstring"""



    lowercase    =					'instructblip_vision_model'

    def __init__(   self    :  List[str]    ,						lowerCamelCase    :  Optional[Any]=14_08    ,						lowerCamelCase    :  int=61_44    ,						lowerCamelCase    :  Any=39    ,						lowerCamelCase    :  Any=16    ,						lowerCamelCase    :  Optional[Any]=2_24    ,						lowerCamelCase    :  List[Any]=14    ,						lowerCamelCase    :  Optional[Any]="gelu"    ,						lowerCamelCase    :  List[str]=1E-6    ,						lowerCamelCase    :  int=0.0    ,						lowerCamelCase    :  Optional[Any]=1E-10    ,						lowerCamelCase    :  Union[str, Any]=True    ,						**lowerCamelCase    :  Any    ,						)   ->  Optional[Any]:
      super().__init__(**lowerCamelCase		)

      lowerCAmelCase_			:      Optional[int]			=   hidden_size
      lowerCAmelCase_			:      Optional[Any]			=   intermediate_size
      lowerCAmelCase_			:      Optional[Any]			=   num_hidden_layers
      lowerCAmelCase_			:      Optional[Any]			=   num_attention_heads
      lowerCAmelCase_			:      List[Any]			=   patch_size
      lowerCAmelCase_			:      List[Any]			=   image_size
      lowerCAmelCase_			:      Tuple			=   initializer_range
      lowerCAmelCase_			:      List[Any]			=   attention_dropout
      lowerCAmelCase_			:      Tuple			=   layer_norm_eps
      lowerCAmelCase_			:      Any			=   hidden_act
      lowerCAmelCase_			:      Optional[int]			=   qkv_bias





    @classmethod
    def __lowercase   (   cls    :  Dict    ,						lowerCamelCase    :  Union[str, os.PathLike]    ,						**lowerCamelCase    :  int		)   ->  "PretrainedConfig":
      cls._set_token_in_kwargs(lowerCamelCase		)

      lowerCAmelCase_,							lowerCAmelCase_			:      Dict			=   cls.get_config_dict(lowerCamelCase    ,						**lowerCamelCase		)

      # get the vision config dict if we are loading from InstructBlipConfig
      if config_dict.get("""model_type"""		) == "instructblip":
        lowerCAmelCase_			:      int			=   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(lowerCamelCase    ,						**lowerCamelCase		)







class    __snake_case       (   _SCREAMING_SNAKE_CASE):







    """simple docstring"""



    lowercase    =					'instructblip_qformer'

    def __init__(   self    :  Any    ,						lowerCamelCase    :  Any=3_05_22    ,						lowerCamelCase    :  Tuple=7_68    ,						lowerCamelCase    :  Union[str, Any]=12    ,						lowerCamelCase    :  List[Any]=12    ,						lowerCamelCase    :  List[str]=30_72    ,						lowerCamelCase    :  Tuple="gelu"    ,						lowerCamelCase    :  int=0.1    ,						lowerCamelCase    :  Any=0.1    ,						lowerCamelCase    :  Optional[Any]=5_12    ,						lowerCamelCase    :  str=0.02    ,						lowerCamelCase    :  Optional[Any]=1E-12    ,						lowerCamelCase    :  int=0    ,						lowerCamelCase    :  int="absolute"    ,						lowerCamelCase    :  str=2    ,						lowerCamelCase    :  str=14_08    ,						**lowerCamelCase    :  List[Any]    ,						)   ->  str:
      super().__init__(pad_token_id=lowerCamelCase    ,						**lowerCamelCase		)

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





    @classmethod
    def __lowercase   (   cls    :  Dict    ,						lowerCamelCase    :  Union[str, os.PathLike]    ,						**lowerCamelCase    :  Optional[int]		)   ->  "PretrainedConfig":
      cls._set_token_in_kwargs(lowerCamelCase		)

      lowerCAmelCase_,							lowerCAmelCase_			:      int			=   cls.get_config_dict(lowerCamelCase    ,						**lowerCamelCase		)

      # get the qformer config dict if we are loading from InstructBlipConfig
      if config_dict.get("""model_type"""		) == "instructblip":
        lowerCAmelCase_			:      str			=   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(lowerCamelCase    ,						**lowerCamelCase		)







class    __snake_case       (   _SCREAMING_SNAKE_CASE):







    """simple docstring"""



    lowercase    =					'instructblip'
    lowercase    =					True

    def __init__(   self    :  List[str]    ,						lowerCamelCase    :  Any=None    ,						lowerCamelCase    :  List[Any]=None    ,						lowerCamelCase    :  str=None    ,						lowerCamelCase    :  Dict=32    ,						**lowerCamelCase    :  Optional[int]		)   ->  Optional[int]:
      super().__init__(**lowerCamelCase		)

      if vision_config is None:
        lowerCAmelCase_			:      str			=   {}
        logger.info("""vision_config is None. initializing the InstructBlipVisionConfig with default values."""		)

      if qformer_config is None:
        lowerCAmelCase_			:      Optional[int]			=   {}
        logger.info("""qformer_config is None. Initializing the InstructBlipQFormerConfig with default values."""		)

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

      lowerCAmelCase_			:      Tuple			=   InstructBlipVisionConfig(**lowerCamelCase		)
      lowerCAmelCase_			:      Optional[int]			=   InstructBlipQFormerConfig(**lowerCamelCase		)
      lowerCAmelCase_			:      Optional[int]			=   text_config["""model_type"""] if """model_type""" in text_config else """opt"""
      lowerCAmelCase_			:      Optional[int]			=   CONFIG_MAPPING[text_model_type](**lowerCamelCase		)

      lowerCAmelCase_			:      int			=   self.text_config.tie_word_embeddings
      lowerCAmelCase_			:      Any			=   self.text_config.is_encoder_decoder

      lowerCAmelCase_			:      int			=   num_query_tokens
      lowerCAmelCase_			:      str			=   self.vision_config.hidden_size
      lowerCAmelCase_			:      List[Any]			=   self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
      lowerCAmelCase_			:      int			=   1.0
      lowerCAmelCase_			:      List[str]			=   0.02

    @classmethod
    def __lowercase   (   cls    :  Tuple    ,						lowerCamelCase    :  InstructBlipVisionConfig    ,						lowerCamelCase    :  InstructBlipQFormerConfig    ,						lowerCamelCase    :  PretrainedConfig    ,						**lowerCamelCase    :  Any    ,						)   ->  int:
      return cls(
          vision_config=vision_config.to_dict()    ,						qformer_config=qformer_config.to_dict()    ,						text_config=text_config.to_dict()    ,						**lowerCamelCase    ,						)





    def __lowercase   (   self    :  int		)   ->  Any:
      lowerCAmelCase_			:      Union[str, Any]			=   copy.deepcopy(self.__dict__		)
      lowerCAmelCase_			:      Union[str, Any]			=   self.vision_config.to_dict()
      lowerCAmelCase_			:      str			=   self.qformer_config.to_dict()
      lowerCAmelCase_			:      Union[str, Any]			=   self.text_config.to_dict()
      lowerCAmelCase_			:      List[Any]			=   self.__class__.model_type
      return output







'''simple docstring'''






def 				UpperCamelCase_			(    A__					:   int					):
  '''simple docstring'''





  lowerCAmelCase_			:      Union[str, Any]			=   (1 + 24 * n) ** 0.5
  return ((1 + root) / 6) % 1 == 0







def 				UpperCamelCase_			(    A__					:   int = 50_00					):
  '''simple docstring'''





  lowerCAmelCase_			:      Optional[int]			=   [(i * (3 * i - 1)) // 2 for i in range(1							,    A__					)]
  for i, pentagonal_i in enumerate(A__					):
    for j in range(A__							,    len(A__					)					):
      lowerCAmelCase_			:      int			=   pentagonal_nums[j]
      lowerCAmelCase_			:      Union[str, Any]			=   pentagonal_i + pentagonal_j
      lowerCAmelCase_			:      List[Any]			=   pentagonal_j - pentagonal_i
      if is_pentagonal(A__					) and is_pentagonal(A__					):
        return b

  return -1


if __name__ == "__main__":
  print(F'''{solution() = }''')



