






'''simple docstring'''





import copy
import os
from typing import Union

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


__A							:							Any  							=		logging.get_logger(__name__)

__A							:							List[Any]  							=		{
    """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     :     Dict				,     __lowerCamelCase     :     Any=30524				,     __lowerCamelCase     :     Dict=768				,     __lowerCamelCase     :     List[str]=768				,     __lowerCamelCase     :     Tuple=3072				,     __lowerCamelCase     :     Optional[int]=768				,     __lowerCamelCase     :     Optional[Any]=12				,     __lowerCamelCase     :     str=8				,     __lowerCamelCase     :     List[str]=512				,     __lowerCamelCase     :     Optional[Any]="gelu"				,     __lowerCamelCase     :     Union[str, Any]=1E-12				,     __lowerCamelCase     :     int=0.0				,     __lowerCamelCase     :     List[str]=0.0				,     __lowerCamelCase     :     Optional[int]=0.0_2				,     __lowerCamelCase     :     Dict=30522				,     __lowerCamelCase     :     Any=2				,     __lowerCamelCase     :     Optional[Any]=0				,     __lowerCamelCase     :     Optional[Any]=102				,     __lowerCamelCase     :     List[Any]=True				,     __lowerCamelCase     :     str=True				,     **__lowerCamelCase     :     Optional[Any]				,     )							->							str:

     '''simple docstring'''




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

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




    @classmethod
    def    a__				(					cls     :     Tuple				,     __lowerCamelCase     :     Union[str, os.PathLike]				,     **__lowerCamelCase     :     Optional[Any]     )							->							"PretrainedConfig":

     '''simple docstring'''




     cls._set_token_in_kwargs(__lowerCamelCase     )

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

     # get the text config dict if we are loading from BlipConfig
     if config_dict.get("model_type"     ) == "blip":
      lowerCamelCase__  =     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     :     Any				,     __lowerCamelCase     :     Optional[Any]=768				,     __lowerCamelCase     :     Any=3072				,     __lowerCamelCase     :     List[Any]=512				,     __lowerCamelCase     :     List[Any]=12				,     __lowerCamelCase     :     List[Any]=12				,     __lowerCamelCase     :     Tuple=384				,     __lowerCamelCase     :     Dict=16				,     __lowerCamelCase     :     Optional[int]="gelu"				,     __lowerCamelCase     :     Tuple=1E-5				,     __lowerCamelCase     :     List[str]=0.0				,     __lowerCamelCase     :     Dict=1E-10				,     **__lowerCamelCase     :     Union[str, Any]				,     )							->							str:

     '''simple docstring'''




     super().__init__(**__lowerCamelCase     )

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




    @classmethod
    def    a__				(					cls     :     Optional[Any]				,     __lowerCamelCase     :     Union[str, os.PathLike]				,     **__lowerCamelCase     :     List[Any]     )							->							"PretrainedConfig":

     '''simple docstring'''




     cls._set_token_in_kwargs(__lowerCamelCase     )

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

     # get the vision config dict if we are loading from BlipConfig
     if config_dict.get("model_type"     ) == "blip":
      lowerCamelCase__  =     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     :     Any				,     __lowerCamelCase     :     Any=None				,     __lowerCamelCase     :     Any=None				,     __lowerCamelCase     :     Dict=512				,     __lowerCamelCase     :     Optional[Any]=2.6_5_9_2				,     __lowerCamelCase     :     Tuple=256				,     **__lowerCamelCase     :     List[str]				,     )							->							Any:

     '''simple docstring'''




     super().__init__(**__lowerCamelCase     )

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

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

     lowerCamelCase__  =     BlipTextConfig(**__lowerCamelCase     )
     lowerCamelCase__  =     BlipVisionConfig(**__lowerCamelCase     )

     lowerCamelCase__  =     self.vision_config.hidden_size

     lowerCamelCase__  =     projection_dim
     lowerCamelCase__  =     logit_scale_init_value
     lowerCamelCase__  =     1.0
     lowerCamelCase__  =     0.0_2
     lowerCamelCase__  =     image_text_hidden_size

    @classmethod
    def    a__				(					cls     :     Optional[int]				,     __lowerCamelCase     :     BlipTextConfig				,     __lowerCamelCase     :     BlipVisionConfig				,     **__lowerCamelCase     :     Dict     )							->							Tuple:

     '''simple docstring'''




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




    def    a__				(					self     :     str     )							->							int:

     '''simple docstring'''




     lowerCamelCase__  =     copy.deepcopy(self.__dict__     )
     lowerCamelCase__  =     self.text_config.to_dict()
     lowerCamelCase__  =     self.vision_config.to_dict()
     lowerCamelCase__  =     self.__class__.model_type
     return output









'''simple docstring'''





from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


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

__A							:							int  							=		{
    """google/vit-base-patch16-224""": """https://huggingface.co/vit-base-patch16-224/resolve/main/config.json""",
    # See all ViT models at https://huggingface.co/models?filter=vit
}
class 				lowercase       (							_lowerCamelCase      ):


    '''simple docstring'''

    lowerCAmelCase__      				=							"vit"

    def __init__(					self     :     Optional[int]				,     __lowerCamelCase     :     Tuple=768				,     __lowerCamelCase     :     Tuple=12				,     __lowerCamelCase     :     Tuple=12				,     __lowerCamelCase     :     int=3072				,     __lowerCamelCase     :     Optional[Any]="gelu"				,     __lowerCamelCase     :     Optional[int]=0.0				,     __lowerCamelCase     :     Tuple=0.0				,     __lowerCamelCase     :     Optional[Any]=0.0_2				,     __lowerCamelCase     :     int=1E-12				,     __lowerCamelCase     :     Tuple=224				,     __lowerCamelCase     :     int=16				,     __lowerCamelCase     :     Optional[int]=3				,     __lowerCamelCase     :     List[str]=True				,     __lowerCamelCase     :     str=16				,     **__lowerCamelCase     :     Optional[int]				,     )							->							str:

     '''simple docstring'''




     super().__init__(**__lowerCamelCase     )

     lowerCamelCase__  =     hidden_size
     lowerCamelCase__  =     num_hidden_layers
     lowerCamelCase__  =     num_attention_heads
     lowerCamelCase__  =     intermediate_size
     lowerCamelCase__  =     hidden_act
     lowerCamelCase__  =     hidden_dropout_prob
     lowerCamelCase__  =     attention_probs_dropout_prob
     lowerCamelCase__  =     initializer_range
     lowerCamelCase__  =     layer_norm_eps
     lowerCamelCase__  =     image_size
     lowerCamelCase__  =     patch_size
     lowerCamelCase__  =     num_channels
     lowerCamelCase__  =     qkv_bias
     lowerCamelCase__  =     encoder_stride
class 				lowercase       (							_lowerCamelCase      ):


    '''simple docstring'''

    lowerCAmelCase__      				=							version.parse("1.11"      )

    @property
    def    a__				(					self     :     Optional[int]     )							->							Mapping[str, Mapping[int, str]]:

     '''simple docstring'''




     return OrderedDict(
         [
             ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
         ]     )




    @property
    def    a__				(					self     :     Optional[int]     )							->							float:

     '''simple docstring'''




     return 1E-4

