



'''simple docstring'''






import copy
import os
from typing import Union

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


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

lowerCAmelCase: List[str]							=						{
    '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 							a__( lowerCamelCase__     ):
    lowercase__			=   """blip_text_model"""







    def __init__(				self			:  int						,      __snake_case			:  Dict=3_05_24						,      __snake_case			:  str=7_68						,      __snake_case			:  str=7_68						,      __snake_case			:  List[str]=30_72						,      __snake_case			:  Optional[int]=7_68						,      __snake_case			:  List[Any]=12						,      __snake_case			:  Dict=8						,      __snake_case			:  Tuple=5_12						,      __snake_case			:  Any="gelu"						,      __snake_case			:  Any=1e-1_2						,      __snake_case			:  Optional[Any]=0.0						,      __snake_case			:  Union[str, Any]=0.0						,      __snake_case			:  Union[str, Any]=0.02						,      __snake_case			:  Optional[Any]=3_05_22						,      __snake_case			:  List[str]=2						,      __snake_case			:  Any=0						,      __snake_case			:  Optional[int]=1_02						,      __snake_case			:  Tuple=True						,      __snake_case			:  Dict=True						,      **__snake_case			:  Optional[int]						,      ):
      super().__init__(
          pad_token_id=__snake_case						,      bos_token_id=__snake_case						,      eos_token_id=__snake_case						,      sep_token_id=__snake_case						,      **__snake_case						,      )

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







    @classmethod
    def       lowercase_	(				cls			:  Optional[Any]						,      __snake_case			:  Union[str, os.PathLike]						,      **__snake_case			:  List[str]     ):
      cls._set_token_in_kwargs(__snake_case     )

      a       ,     a						: Optional[int]					       =					cls.get_config_dict(__snake_case						,      **__snake_case     )

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

class 							a__( lowerCamelCase__     ):
    lowercase__			=   """blip_vision_model"""







    def __init__(				self			:  Dict						,      __snake_case			:  Optional[Any]=7_68						,      __snake_case			:  Dict=30_72						,      __snake_case			:  str=5_12						,      __snake_case			:  Any=12						,      __snake_case			:  int=12						,      __snake_case			:  Optional[Any]=3_84						,      __snake_case			:  str=16						,      __snake_case			:  str="gelu"						,      __snake_case			:  Union[str, Any]=1e-5						,      __snake_case			:  Any=0.0						,      __snake_case			:  List[Any]=1e-1_0						,      **__snake_case			:  Tuple						,      ):
      super().__init__(**__snake_case     )

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







    @classmethod
    def       lowercase_	(				cls			:  Dict						,      __snake_case			:  Union[str, os.PathLike]						,      **__snake_case			:  Union[str, Any]     ):
      cls._set_token_in_kwargs(__snake_case     )

      a       ,     a						: int					       =					cls.get_config_dict(__snake_case						,      **__snake_case     )

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

class 							a__( lowerCamelCase__     ):
    lowercase__			=   """blip"""
    lowercase__			=   True







    def __init__(				self			:  List[Any]						,      __snake_case			:  Optional[Any]=None						,      __snake_case			:  Optional[Any]=None						,      __snake_case			:  Optional[int]=5_12						,      __snake_case			:  Tuple=2.6592						,      __snake_case			:  Tuple=2_56						,      **__snake_case			:  Any						,      ):
      super().__init__(**__snake_case     )

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

      if vision_config is None:
        a						: List[str]					       =					{}
        logger.info('`vision_config` is `None`. Initializing the `BlipVisionConfig` with default values.'     )

      a						: Optional[Any]					       =					BlipTextConfig(**__snake_case     )
      a						: str					       =					BlipVisionConfig(**__snake_case     )

      a						: Tuple					       =					self.vision_config.hidden_size

      a						: Any					       =					projection_dim
      a						: List[Any]					       =					logit_scale_init_value
      a						: Tuple					       =					1.0
      a						: Optional[Any]					       =					0.02
      a						: str					       =					image_text_hidden_size







    @classmethod
    def       lowercase_	(				cls			:  int						,      __snake_case			:  BlipTextConfig						,      __snake_case			:  BlipVisionConfig						,      **__snake_case			:  Dict     ):
      return cls(text_config=text_config.to_dict()						,      vision_config=vision_config.to_dict()						,      **__snake_case     )







    def       lowercase_	(				self			:  Optional[int]     ):
      a						: int					       =					copy.deepcopy(self.__dict__     )
      a						: Any					       =					self.text_config.to_dict()
      a						: Optional[Any]					       =					self.vision_config.to_dict()
      a						: Optional[int]					       =					self.__class__.model_type
      return output




'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
)


lowerCAmelCase: List[Any]							=						{}

try:
     if not is_sentencepiece_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCAmelCase: Optional[int]							=						['NllbTokenizer']

try:
     if not is_tokenizers_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCAmelCase: Dict							=						['NllbTokenizerFast']


if TYPE_CHECKING:
     try:
          if not is_sentencepiece_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_nllb import NllbTokenizer

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_nllb_fast import NllbTokenizerFast

else:
     import sys

     lowerCAmelCase: Tuple							=						_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)