


'''simple docstring'''







import copy
import os
from typing import Union

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


A				:					Optional[int]    						=			logging.get_logger(__name__)

A				:					int    						=			{
    '''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 			__lowerCamelCase			(	a_	):
    """simple docstring"""
    a													=   "blip_text_model"


    def __init__(  self      :							Optional[int]				,							SCREAMING_SNAKE_CASE      :							List[Any]=30524				,							SCREAMING_SNAKE_CASE      :							Optional[Any]=768				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]=768				,							SCREAMING_SNAKE_CASE      :							Tuple=3072				,							SCREAMING_SNAKE_CASE      :							Any=768				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]=12				,							SCREAMING_SNAKE_CASE      :							Dict=8				,							SCREAMING_SNAKE_CASE      :							List[str]=512				,							SCREAMING_SNAKE_CASE      :							Any="gelu"				,							SCREAMING_SNAKE_CASE      :							Dict=1e-12				,							SCREAMING_SNAKE_CASE      :							Tuple=0.0				,							SCREAMING_SNAKE_CASE      :							Optional[Any]=0.0				,							SCREAMING_SNAKE_CASE      :							int=0.02				,							SCREAMING_SNAKE_CASE      :							List[str]=30522				,							SCREAMING_SNAKE_CASE      :							Any=2				,							SCREAMING_SNAKE_CASE      :							Tuple=0				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]=102				,							SCREAMING_SNAKE_CASE      :							Dict=True				,							SCREAMING_SNAKE_CASE      :							List[str]=True				,							**SCREAMING_SNAKE_CASE      :							Tuple				,							):
           super().__init__(
               pad_token_id=SCREAMING_SNAKE_CASE				,							bos_token_id=SCREAMING_SNAKE_CASE				,							eos_token_id=SCREAMING_SNAKE_CASE				,							sep_token_id=SCREAMING_SNAKE_CASE				,							**SCREAMING_SNAKE_CASE				,							)

           _A					:     Tuple     = vocab_size
           _A					:     Any     = hidden_size
           _A					:     Tuple     = encoder_hidden_size
           _A					:     List[str]     = intermediate_size
           _A					:     List[str]     = projection_dim
           _A					:     Any     = hidden_dropout_prob
           _A					:     Optional[int]     = num_hidden_layers
           _A					:     Optional[Any]     = num_attention_heads
           _A					:     Optional[Any]     = max_position_embeddings
           _A					:     int     = layer_norm_eps
           _A					:     str     = hidden_act
           _A					:     List[Any]     = initializer_range
           _A					:     Tuple     = attention_probs_dropout_prob
           _A					:     str     = is_decoder
           _A					:     Optional[Any]     = use_cache


    @classmethod
    def        A   (  cls      :							List[str]				,							SCREAMING_SNAKE_CASE      :							Union[str, os.PathLike]				,							**SCREAMING_SNAKE_CASE      :							Any):
           cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE)

           _A  ,			_A					:     Any     = cls.get_config_dict(SCREAMING_SNAKE_CASE				,							**SCREAMING_SNAKE_CASE)

           # get the text config dict if we are loading from BlipConfig
           if config_dict.get('model_type') == "blip":
                  _A					:     Tuple     = 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(SCREAMING_SNAKE_CASE				,							**SCREAMING_SNAKE_CASE)




class 			__lowerCamelCase			(	a_	):
    """simple docstring"""
    a													=   "blip_vision_model"


    def __init__(  self      :							Optional[Any]				,							SCREAMING_SNAKE_CASE      :							Tuple=768				,							SCREAMING_SNAKE_CASE      :							str=3072				,							SCREAMING_SNAKE_CASE      :							Dict=512				,							SCREAMING_SNAKE_CASE      :							Any=12				,							SCREAMING_SNAKE_CASE      :							Union[str, Any]=12				,							SCREAMING_SNAKE_CASE      :							List[str]=384				,							SCREAMING_SNAKE_CASE      :							Optional[int]=16				,							SCREAMING_SNAKE_CASE      :							int="gelu"				,							SCREAMING_SNAKE_CASE      :							Any=1e-5				,							SCREAMING_SNAKE_CASE      :							Optional[Any]=0.0				,							SCREAMING_SNAKE_CASE      :							str=1e-10				,							**SCREAMING_SNAKE_CASE      :							List[Any]				,							):
           super().__init__(**SCREAMING_SNAKE_CASE)

           _A					:     str     = hidden_size
           _A					:     Tuple     = intermediate_size
           _A					:     str     = projection_dim
           _A					:     Optional[int]     = num_hidden_layers
           _A					:     Optional[int]     = num_attention_heads
           _A					:     Tuple     = patch_size
           _A					:     Optional[int]     = image_size
           _A					:     Any     = initializer_range
           _A					:     List[Any]     = attention_dropout
           _A					:     int     = layer_norm_eps
           _A					:     str     = hidden_act


    @classmethod
    def        A   (  cls      :							List[str]				,							SCREAMING_SNAKE_CASE      :							Union[str, os.PathLike]				,							**SCREAMING_SNAKE_CASE      :							List[str]):
           cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE)

           _A  ,			_A					:     Tuple     = cls.get_config_dict(SCREAMING_SNAKE_CASE				,							**SCREAMING_SNAKE_CASE)

           # get the vision config dict if we are loading from BlipConfig
           if config_dict.get('model_type') == "blip":
                  _A					:     List[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(SCREAMING_SNAKE_CASE				,							**SCREAMING_SNAKE_CASE)




class 			__lowerCamelCase			(	a_	):
    """simple docstring"""
    a													=   "blip"
    a													=   True


    def __init__(  self      :							Union[str, Any]				,							SCREAMING_SNAKE_CASE      :							Any=None				,							SCREAMING_SNAKE_CASE      :							Optional[Any]=None				,							SCREAMING_SNAKE_CASE      :							Optional[Any]=512				,							SCREAMING_SNAKE_CASE      :							List[str]=2.6592				,							SCREAMING_SNAKE_CASE      :							Optional[int]=256				,							**SCREAMING_SNAKE_CASE      :							Any				,							):
           super().__init__(**SCREAMING_SNAKE_CASE)

           if text_config is None:
                  _A					:     Optional[Any]     = {}
                  logger.info('`text_config` is `None`. Initializing the `BlipTextConfig` with default values.')

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

           _A					:     Tuple     = BlipTextConfig(**SCREAMING_SNAKE_CASE)
           _A					:     Optional[Any]     = BlipVisionConfig(**SCREAMING_SNAKE_CASE)

           _A					:     Any     = self.vision_config.hidden_size

           _A					:     int     = projection_dim
           _A					:     Dict     = logit_scale_init_value
           _A					:     Any     = 1.0
           _A					:     List[str]     = 0.02
           _A					:     Tuple     = image_text_hidden_size


    @classmethod
    def        A   (  cls      :							Dict				,							SCREAMING_SNAKE_CASE      :							BlipTextConfig				,							SCREAMING_SNAKE_CASE      :							BlipVisionConfig				,							**SCREAMING_SNAKE_CASE      :							List[str]):
           return cls(text_config=text_config.to_dict()				,							vision_config=vision_config.to_dict()				,							**SCREAMING_SNAKE_CASE)


    def        A   (  self      :							List[Any]):
           _A					:     Tuple     = copy.deepcopy(self.__dict__)
           _A					:     str     = self.text_config.to_dict()
           _A					:     List[str]     = self.vision_config.to_dict()
           _A					:     List[Any]     = self.__class__.model_type
           return output










'''simple docstring'''







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


A				:					Optional[int]    						=			{
    '''configuration_mask2former''': [
        '''MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''Mask2FormerConfig''',
    ],
}

try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   A				:					Tuple    						=			['''Mask2FormerImageProcessor''']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   A				:					Dict    						=			[
       '''MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''Mask2FormerForUniversalSegmentation''',
       '''Mask2FormerModel''',
       '''Mask2FormerPreTrainedModel''',
   ]

if TYPE_CHECKING:
   from .configuration_maskaformer import MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, MaskaFormerConfig

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .image_processing_maskaformer import MaskaFormerImageProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_maskaformer import (
          MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
          MaskaFormerForUniversalSegmentation,
          MaskaFormerModel,
          MaskaFormerPreTrainedModel,
      )


else:
   import sys

   A				:					Optional[Any]    						=			_LazyModule(__name__, globals()['''__file__'''], _import_structure)






