


'''simple docstring'''



import copy
import os
from typing import Union

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


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

_lowercase      :      Tuple            =					{
    """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 	UpperCamelCase__(       lowerCAmelCase	):
				__magic_name__    :				Any  		=	"blip_text_model"




				def __init__(		self      :			Dict				,   lowerCAmelCase      :			Optional[int]=30524				,   lowerCAmelCase      :			int=768				,   lowerCAmelCase      :			Union[str, Any]=768				,   lowerCAmelCase      :			Dict=3072				,   lowerCAmelCase      :			Optional[int]=768				,   lowerCAmelCase      :			List[Any]=12				,   lowerCAmelCase      :			Dict=8				,   lowerCAmelCase      :			Tuple=512				,   lowerCAmelCase      :			Optional[Any]="gelu"				,   lowerCAmelCase      :			Any=1E-12				,   lowerCAmelCase      :			Any=0.0				,   lowerCAmelCase      :			Union[str, Any]=0.0				,   lowerCAmelCase      :			List[str]=0.02				,   lowerCAmelCase      :			int=30522				,   lowerCAmelCase      :			Optional[Any]=2				,   lowerCAmelCase      :			int=0				,   lowerCAmelCase      :			Optional[Any]=102				,   lowerCAmelCase      :			Tuple=True				,   lowerCAmelCase      :			Dict=True				,   **lowerCAmelCase      :			Union[str, Any]				,   )->					int:

										"""simple docstring"""




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

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





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

										"""simple docstring"""




										cls._set_token_in_kwargs(lowerCAmelCase				)

										UpperCAmelCase    ,    UpperCAmelCase					    =     cls.get_config_dict(lowerCAmelCase				,   **lowerCAmelCase				)

										# get the text config dict if we are loading from BlipConfig
										if config_dict.get('''model_type'''				) == "blip":
																UpperCAmelCase					    =     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 	UpperCamelCase__(       lowerCAmelCase	):
				__magic_name__    :				str  		=	"blip_vision_model"




				def __init__(		self      :			List[str]				,   lowerCAmelCase      :			int=768				,   lowerCAmelCase      :			List[Any]=3072				,   lowerCAmelCase      :			Union[str, Any]=512				,   lowerCAmelCase      :			str=12				,   lowerCAmelCase      :			Any=12				,   lowerCAmelCase      :			int=384				,   lowerCAmelCase      :			Dict=16				,   lowerCAmelCase      :			Dict="gelu"				,   lowerCAmelCase      :			Dict=1E-5				,   lowerCAmelCase      :			Optional[int]=0.0				,   lowerCAmelCase      :			Optional[int]=1E-10				,   **lowerCAmelCase      :			int				,   )->					List[str]:

										"""simple docstring"""




										super().__init__(**lowerCAmelCase				)

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





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

										"""simple docstring"""




										cls._set_token_in_kwargs(lowerCAmelCase				)

										UpperCAmelCase    ,    UpperCAmelCase					    =     cls.get_config_dict(lowerCAmelCase				,   **lowerCAmelCase				)

										# get the vision config dict if we are loading from BlipConfig
										if config_dict.get('''model_type'''				) == "blip":
																UpperCAmelCase					    =     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 	UpperCamelCase__(       lowerCAmelCase	):
				__magic_name__    :				Optional[int]  		=	"blip"
				__magic_name__    :				List[Any]  		=	True




				def __init__(		self      :			Tuple				,   lowerCAmelCase      :			List[str]=None				,   lowerCAmelCase      :			List[str]=None				,   lowerCAmelCase      :			Any=512				,   lowerCAmelCase      :			int=2.6592				,   lowerCAmelCase      :			List[str]=256				,   **lowerCAmelCase      :			Optional[Any]				,   )->					str:

										"""simple docstring"""




										super().__init__(**lowerCAmelCase				)

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

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

										UpperCAmelCase					    =     BlipTextConfig(**lowerCAmelCase				)
										UpperCAmelCase					    =     BlipVisionConfig(**lowerCAmelCase				)

										UpperCAmelCase					    =     self.vision_config.hidden_size

										UpperCAmelCase					    =     projection_dim
										UpperCAmelCase					    =     logit_scale_init_value
										UpperCAmelCase					    =     1.0
										UpperCAmelCase					    =     0.02
										UpperCAmelCase					    =     image_text_hidden_size




				@classmethod
				def 					a__(		cls      :			str				,   lowerCAmelCase      :			BlipTextConfig				,   lowerCAmelCase      :			BlipVisionConfig				,   **lowerCAmelCase      :			Any				)->					List[Any]:

										"""simple docstring"""




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





				def 					a__(		self      :			Any				)->					Tuple:

										"""simple docstring"""




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









'''simple docstring'''



from .data_collator import (
    DataCollatorForLanguageModeling,
    DataCollatorForPermutationLanguageModeling,
    DataCollatorForSeqaSeq,
    DataCollatorForSOP,
    DataCollatorForTokenClassification,
    DataCollatorForWholeWordMask,
    DataCollatorWithPadding,
    DefaultDataCollator,
    default_data_collator,
)
from .metrics import glue_compute_metrics, xnli_compute_metrics
from .processors import (
    DataProcessor,
    InputExample,
    InputFeatures,
    SingleSentenceClassificationProcessor,
    SquadExample,
    SquadFeatures,
    SquadVaProcessor,
    SquadVaProcessor,
    glue_convert_examples_to_features,
    glue_output_modes,
    glue_processors,
    glue_tasks_num_labels,
    squad_convert_examples_to_features,
    xnli_output_modes,
    xnli_processors,
    xnli_tasks_num_labels,
)





