


'''simple docstring'''



import copy
import os
from typing import Union

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


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

_lowercase    :    Union[str, 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  UpperCamelCase__(     lowerCAmelCase ):
				__magic_name__       :   List[str]							= "blip_text_model"




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

										"""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    :				Tuple   ,					lowerCAmelCase    :				Union[str, os.PathLike]   ,					**lowerCAmelCase    :				Any   )->  "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__       :   int							= "blip_vision_model"




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

										"""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    :				Any   ,					lowerCAmelCase    :				Union[str, os.PathLike]   ,					**lowerCAmelCase    :				int   )->  "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[Any]							= "blip"
				__magic_name__       :   int							= True




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

										"""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    :				Union[str, Any]   ,					lowerCAmelCase    :				BlipTextConfig   ,					lowerCAmelCase    :				BlipVisionConfig   ,					**lowerCAmelCase    :				int   )->  str:

										"""simple docstring"""




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





				def   a__(	self    :				str   )->  str:

										"""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'''



# Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


_lowercase    :    Any			     =  {
    """configuration_cpmant""": ["""CPMANT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CpmAntConfig"""],
    """tokenization_cpmant""": ["""CpmAntTokenizer"""],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_lowercase    :    int			     =  [
	    """CPMANT_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """CpmAntForCausalLM""",
	    """CpmAntModel""",
	    """CpmAntPreTrainedModel""",
	]


if TYPE_CHECKING:
	from .configuration_cpmant import CPMANT_PRETRAINED_CONFIG_ARCHIVE_MAP, CpmAntConfig
	from .tokenization_cpmant import CpmAntTokenizer

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_cpmant import (
		    CPMANT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    CpmAntForCausalLM,
		    CpmAntModel,
		    CpmAntPreTrainedModel,
		)


else:
	import sys

	_lowercase    :    Dict			     =  _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





