




'''simple docstring'''



import copy
import os
from typing import Union

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


lowerCamelCase_			=						logging.get_logger(__name__)

lowerCamelCase_			=						{
    """Salesforce/blip-vqa-base""": """https://huggingface.co/Salesforce/blip-vqa-base/resolve/main/config.json""",
    """Salesforce/blip-vqa-capfit-large""": (
        """https://huggingface.co/Salesforce/blip-vqa-base-capfit/resolve/main/config.json"""
    ),
    """Salesforce/blip-image-captioning-base""": (
        """https://huggingface.co/Salesforce/blip-image-captioning-base/resolve/main/config.json"""
    ),
    """Salesforce/blip-image-captioning-large""": (
        """https://huggingface.co/Salesforce/blip-image-captioning-large/resolve/main/config.json"""
    ),
    """Salesforce/blip-itm-base-coco""": """https://huggingface.co/Salesforce/blip-itm-base-coco/resolve/main/config.json""",
    """Salesforce/blip-itm-large-coco""": """https://huggingface.co/Salesforce/blip-itm-large-coco/resolve/main/config.json""",
    """Salesforce/blip-itm-base-flikr""": """https://huggingface.co/Salesforce/blip-itm-base-flikr/resolve/main/config.json""",
    """Salesforce/blip-itm-large-flikr""": (
        """https://huggingface.co/Salesforce/blip-itm-large-flikr/resolve/main/config.json"""
    ),
}







class 		lowercase_   (			lowerCamelCase__       ):


   """simple docstring"""

   lowerCamelCase_      =						'blip_text_model'



   def __init__(   self :     Tuple  ,				__lowerCamelCase :     Optional[int]=3_0_5_2_4  ,				__lowerCamelCase :     List[Any]=7_6_8  ,				__lowerCamelCase :     List[Any]=7_6_8  ,				__lowerCamelCase :     int=3_0_7_2  ,				__lowerCamelCase :     List[str]=7_6_8  ,				__lowerCamelCase :     List[str]=1_2  ,				__lowerCamelCase :     Union[str, Any]=8  ,				__lowerCamelCase :     List[str]=5_1_2  ,				__lowerCamelCase :     List[Any]="gelu"  ,				__lowerCamelCase :     Tuple=1e-12  ,				__lowerCamelCase :     int=0.0  ,				__lowerCamelCase :     int=0.0  ,				__lowerCamelCase :     Tuple=0.0_2  ,				__lowerCamelCase :     Any=3_0_5_2_2  ,				__lowerCamelCase :     Optional[int]=2  ,				__lowerCamelCase :     Optional[Any]=0  ,				__lowerCamelCase :     List[str]=1_0_2  ,				__lowerCamelCase :     Optional[int]=True  ,				__lowerCamelCase :     int=True  ,				**__lowerCamelCase :     Optional[Any]  ,				):

      """simple docstring"""
      super().__init__(
          pad_token_id=__lowerCamelCase  ,				bos_token_id=__lowerCamelCase  ,				eos_token_id=__lowerCamelCase  ,				sep_token_id=__lowerCamelCase  ,				**__lowerCamelCase  ,				)

      _SCREAMING_SNAKE_CASE	=				vocab_size
      _SCREAMING_SNAKE_CASE	=				hidden_size
      _SCREAMING_SNAKE_CASE	=				encoder_hidden_size
      _SCREAMING_SNAKE_CASE	=				intermediate_size
      _SCREAMING_SNAKE_CASE	=				projection_dim
      _SCREAMING_SNAKE_CASE	=				hidden_dropout_prob
      _SCREAMING_SNAKE_CASE	=				num_hidden_layers
      _SCREAMING_SNAKE_CASE	=				num_attention_heads
      _SCREAMING_SNAKE_CASE	=				max_position_embeddings
      _SCREAMING_SNAKE_CASE	=				layer_norm_eps
      _SCREAMING_SNAKE_CASE	=				hidden_act
      _SCREAMING_SNAKE_CASE	=				initializer_range
      _SCREAMING_SNAKE_CASE	=				attention_probs_dropout_prob
      _SCREAMING_SNAKE_CASE	=				is_decoder
      _SCREAMING_SNAKE_CASE	=				use_cache



   @classmethod
   def 							lowerCAmelCase_      (   cls :     List[Any]  ,				__lowerCamelCase :     str  ,				**__lowerCamelCase :     Tuple   ):

      """simple docstring"""
      cls._set_token_in_kwargs(__lowerCamelCase   )

      _SCREAMING_SNAKE_CASE,	_SCREAMING_SNAKE_CASE	=				cls.get_config_dict(__lowerCamelCase  ,				**__lowerCamelCase   )

      # get the text config dict if we are loading from BlipConfig
      if config_dict.get("model_type"   ) == "blip":
         _SCREAMING_SNAKE_CASE	=				config_dict["text_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 		lowercase_   (			lowerCamelCase__       ):


   """simple docstring"""

   lowerCamelCase_      =						'blip_vision_model'



   def __init__(   self :     Union[str, Any]  ,				__lowerCamelCase :     Union[str, Any]=7_6_8  ,				__lowerCamelCase :     Tuple=3_0_7_2  ,				__lowerCamelCase :     Tuple=5_1_2  ,				__lowerCamelCase :     Union[str, Any]=1_2  ,				__lowerCamelCase :     List[str]=1_2  ,				__lowerCamelCase :     Dict=3_8_4  ,				__lowerCamelCase :     Tuple=1_6  ,				__lowerCamelCase :     List[str]="gelu"  ,				__lowerCamelCase :     Tuple=1e-5  ,				__lowerCamelCase :     int=0.0  ,				__lowerCamelCase :     Optional[Any]=1e-10  ,				**__lowerCamelCase :     int  ,				):

      """simple docstring"""
      super().__init__(**__lowerCamelCase   )

      _SCREAMING_SNAKE_CASE	=				hidden_size
      _SCREAMING_SNAKE_CASE	=				intermediate_size
      _SCREAMING_SNAKE_CASE	=				projection_dim
      _SCREAMING_SNAKE_CASE	=				num_hidden_layers
      _SCREAMING_SNAKE_CASE	=				num_attention_heads
      _SCREAMING_SNAKE_CASE	=				patch_size
      _SCREAMING_SNAKE_CASE	=				image_size
      _SCREAMING_SNAKE_CASE	=				initializer_range
      _SCREAMING_SNAKE_CASE	=				attention_dropout
      _SCREAMING_SNAKE_CASE	=				layer_norm_eps
      _SCREAMING_SNAKE_CASE	=				hidden_act



   @classmethod
   def 							lowerCAmelCase_      (   cls :     Any  ,				__lowerCamelCase :     List[str]  ,				**__lowerCamelCase :     int   ):

      """simple docstring"""
      cls._set_token_in_kwargs(__lowerCamelCase   )

      _SCREAMING_SNAKE_CASE,	_SCREAMING_SNAKE_CASE	=				cls.get_config_dict(__lowerCamelCase  ,				**__lowerCamelCase   )

      # get the vision config dict if we are loading from BlipConfig
      if config_dict.get("model_type"   ) == "blip":
         _SCREAMING_SNAKE_CASE	=				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 		lowercase_   (			lowerCamelCase__       ):


   """simple docstring"""

   lowerCamelCase_      =						'blip'
   lowerCamelCase_      =						True



   def __init__(   self :     Union[str, Any]  ,				__lowerCamelCase :     List[str]=None  ,				__lowerCamelCase :     Any=None  ,				__lowerCamelCase :     List[Any]=5_1_2  ,				__lowerCamelCase :     Union[str, Any]=2.6_5_9_2  ,				__lowerCamelCase :     Tuple=2_5_6  ,				**__lowerCamelCase :     Any  ,				):

      """simple docstring"""
      super().__init__(**__lowerCamelCase   )

      if text_config is None:
         _SCREAMING_SNAKE_CASE	=				{}
         logger.info("`text_config` is `None`. Initializing the `BlipTextConfig` with default values."   )

      if vision_config is None:
         _SCREAMING_SNAKE_CASE	=				{}
         logger.info("`vision_config` is `None`. Initializing the `BlipVisionConfig` with default values."   )

      _SCREAMING_SNAKE_CASE	=				BlipTextConfig(**__lowerCamelCase   )
      _SCREAMING_SNAKE_CASE	=				BlipVisionConfig(**__lowerCamelCase   )

      _SCREAMING_SNAKE_CASE	=				self.vision_config.hidden_size

      _SCREAMING_SNAKE_CASE	=				projection_dim
      _SCREAMING_SNAKE_CASE	=				logit_scale_init_value
      _SCREAMING_SNAKE_CASE	=				1.0
      _SCREAMING_SNAKE_CASE	=				0.0_2
      _SCREAMING_SNAKE_CASE	=				image_text_hidden_size



   @classmethod
   def 							lowerCAmelCase_      (   cls :     str  ,				__lowerCamelCase :     List[Any]  ,				__lowerCamelCase :     Union[str, Any]  ,				**__lowerCamelCase :     int   ):

      """simple docstring"""
      return cls(text_config=text_config.to_dict()  ,				vision_config=vision_config.to_dict()  ,				**__lowerCamelCase   )



   def 							lowerCAmelCase_      (   self :     Tuple   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE	=				copy.deepcopy(self.__dict__   )
      _SCREAMING_SNAKE_CASE	=				self.text_config.to_dict()
      _SCREAMING_SNAKE_CASE	=				self.vision_config.to_dict()
      _SCREAMING_SNAKE_CASE	=				self.__class__.model_type
      return output







'''simple docstring'''



# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run

import sys
import warnings
from os.path import abspath, dirname, join


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
lowerCamelCase_			=						abspath(join(dirname(dirname(__file__)), 'src'))
sys.path.insert(1, git_repo_path)

# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action='ignore', category=FutureWarning)
def 			SCREAMING_SNAKE_CASE_			(							__A    :			Dict  )			->			Dict:
   from diffusers.utils.testing_utils import pytest_addoption_shared

   pytest_addoption_shared(__A  )






def 			SCREAMING_SNAKE_CASE_			(							__A    :			List[Any]  )			->			str:
   from diffusers.utils.testing_utils import pytest_terminal_summary_main

   _SCREAMING_SNAKE_CASE	=				terminalreporter.config.getoption("--make-reports"  )
   if make_reports:
      pytest_terminal_summary_main(__A	,					id=__A  )

