





"""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      snake_case						(  __UpperCAmelCase  ):
      lowerCamelCase__         =					"blip_text_model"

      def __init__(     self  :Union[str, Any]		,				_lowerCamelCase  :Union[str, Any]=3_0_5_2_4		,				_lowerCamelCase  :Dict=7_6_8		,				_lowerCamelCase  :List[Any]=7_6_8		,				_lowerCamelCase  :List[Any]=3_0_7_2		,				_lowerCamelCase  :Union[str, Any]=7_6_8		,				_lowerCamelCase  :Union[str, Any]=1_2		,				_lowerCamelCase  :Union[str, Any]=8		,				_lowerCamelCase  :Tuple=5_1_2		,				_lowerCamelCase  :List[Any]="gelu"		,				_lowerCamelCase  :Tuple=1e-12		,				_lowerCamelCase  :Optional[Any]=0.0		,				_lowerCamelCase  :int=0.0		,				_lowerCamelCase  :Optional[int]=0.0_2		,				_lowerCamelCase  :Union[str, Any]=3_0_5_2_2		,				_lowerCamelCase  :Any=2		,				_lowerCamelCase  :Optional[int]=0		,				_lowerCamelCase  :Any=1_0_2		,				_lowerCamelCase  :Union[str, Any]=True		,				_lowerCamelCase  :Dict=True		,				**_lowerCamelCase  :List[str]		,				):
       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__		,				)

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



      @classmethod
      def 		SCREAMING_SNAKE_CASE_     (     cls  :str		,				_lowerCamelCase  :Union[str, os.PathLike]		,				**_lowerCamelCase  :int		):
       cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__		)

       __SCREAMING_SNAKE_CASE				, __SCREAMING_SNAKE_CASE					:     Optional[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":
        __SCREAMING_SNAKE_CASE					:     Any   				=			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      snake_case						(  __UpperCAmelCase  ):
      lowerCamelCase__         =					"blip_vision_model"

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

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



      @classmethod
      def 		SCREAMING_SNAKE_CASE_     (     cls  :List[str]		,				_lowerCamelCase  :Union[str, os.PathLike]		,				**_lowerCamelCase  :Optional[int]		):
       cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__		)

       __SCREAMING_SNAKE_CASE				, __SCREAMING_SNAKE_CASE					:     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":
        __SCREAMING_SNAKE_CASE					:     Dict   				=			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      snake_case						(  __UpperCAmelCase  ):
      lowerCamelCase__         =					"blip"
      lowerCamelCase__         =					True

      def __init__(     self  :Union[str, Any]		,				_lowerCamelCase  :Optional[int]=None		,				_lowerCamelCase  :Tuple=None		,				_lowerCamelCase  :str=5_1_2		,				_lowerCamelCase  :str=2.6_5_9_2		,				_lowerCamelCase  :Any=2_5_6		,				**_lowerCamelCase  :Union[str, Any]		,				):
       super().__init__(**SCREAMING_SNAKE_CASE__		)

       if text_config is None:
        __SCREAMING_SNAKE_CASE					:     List[str]   				=			{}
        logger.info('''`text_config` is `None`. Initializing the `BlipTextConfig` with default values.'''		)

       if vision_config is None:
        __SCREAMING_SNAKE_CASE					:     Optional[int]   				=			{}
        logger.info('''`vision_config` is `None`. Initializing the `BlipVisionConfig` with default values.'''		)

       __SCREAMING_SNAKE_CASE					:     List[str]   				=			BlipTextConfig(**SCREAMING_SNAKE_CASE__		)
       __SCREAMING_SNAKE_CASE					:     Union[str, Any]   				=			BlipVisionConfig(**SCREAMING_SNAKE_CASE__		)

       __SCREAMING_SNAKE_CASE					:     List[Any]   				=			self.vision_config.hidden_size

       __SCREAMING_SNAKE_CASE					:     Optional[Any]   				=			projection_dim
       __SCREAMING_SNAKE_CASE					:     Tuple   				=			logit_scale_init_value
       __SCREAMING_SNAKE_CASE					:     List[Any]   				=			1.0
       __SCREAMING_SNAKE_CASE					:     Union[str, Any]   				=			0.0_2
       __SCREAMING_SNAKE_CASE					:     Union[str, Any]   				=			image_text_hidden_size

      @classmethod
      def 		SCREAMING_SNAKE_CASE_     (     cls  :Any		,				_lowerCamelCase  :BlipTextConfig		,				_lowerCamelCase  :BlipVisionConfig		,				**_lowerCamelCase  :str		):
       return cls(text_config=text_config.to_dict()		,				vision_config=vision_config.to_dict()		,				**SCREAMING_SNAKE_CASE__		)



      def 		SCREAMING_SNAKE_CASE_     (     self  :List[Any]		):
       __SCREAMING_SNAKE_CASE					:     Dict   				=			copy.deepcopy(self.__dict__		)
       __SCREAMING_SNAKE_CASE					:     str   				=			self.text_config.to_dict()
       __SCREAMING_SNAKE_CASE					:     Tuple   				=			self.vision_config.to_dict()
       __SCREAMING_SNAKE_CASE					:     Union[str, Any]   				=			self.__class__.model_type
       return output



# Copyright 2023 The HuggingFace 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_torch_available, is_vision_available


_snake_case      = {
    '''configuration_efficientnet''': [
        '''EFFICIENTNET_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''EfficientNetConfig''',
        '''EfficientNetOnnxConfig''',
    ]
}

try:
 if not is_vision_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 _snake_case      = ['''EfficientNetImageProcessor''']

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 _snake_case      = [
     '''EFFICIENTNET_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''EfficientNetForImageClassification''',
     '''EfficientNetModel''',
     '''EfficientNetPreTrainedModel''',
 ]

if TYPE_CHECKING:
 from .configuration_efficientnet import (
     EFFICIENTNET_PRETRAINED_CONFIG_ARCHIVE_MAP,
     EfficientNetConfig,
     EfficientNetOnnxConfig,
 )

 try:
  if not is_vision_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .image_processing_efficientnet import EfficientNetImageProcessor

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_efficientnet import (
      EFFICIENTNET_PRETRAINED_MODEL_ARCHIVE_LIST,
      EfficientNetForImageClassification,
      EfficientNetModel,
      EfficientNetPreTrainedModel,
  )

else:
 import sys

 _snake_case      = _LazyModule(__name__, globals()['''__file__'''], _import_structure)


