



'''simple docstring'''


import copy
import os
from typing import Union

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


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

_lowerCamelCase      :			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 					SCREAMING_SNAKE_CASE					(    _a						):






    """simple docstring"""





    _SCREAMING_SNAKE_CASE          =    """blip_text_model"""






    def __init__(    self :   List[Any]    ,		UpperCamelCase__ :   Tuple=3_0_5_2_4    ,		UpperCamelCase__ :   List[Any]=7_6_8    ,		UpperCamelCase__ :   Union[str, Any]=7_6_8    ,		UpperCamelCase__ :   List[Any]=3_0_7_2    ,		UpperCamelCase__ :   List[str]=7_6_8    ,		UpperCamelCase__ :   List[str]=1_2    ,		UpperCamelCase__ :   Any=8    ,		UpperCamelCase__ :   List[Any]=5_1_2    ,		UpperCamelCase__ :   List[Any]="gelu"    ,		UpperCamelCase__ :   List[Any]=1E-1_2    ,		UpperCamelCase__ :   List[str]=0.0    ,		UpperCamelCase__ :   Optional[Any]=0.0    ,		UpperCamelCase__ :   Optional[Any]=0.0_2    ,		UpperCamelCase__ :   Optional[int]=3_0_5_2_2    ,		UpperCamelCase__ :   str=2    ,		UpperCamelCase__ :   Optional[Any]=0    ,		UpperCamelCase__ :   List[Any]=1_0_2    ,		UpperCamelCase__ :   Union[str, Any]=True    ,		UpperCamelCase__ :   str=True    ,		**UpperCamelCase__ :   Any    ,		):


       """simple docstring"""







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

       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 :   Optional[Any]    ,		UpperCamelCase__ :   Dict    ,		**UpperCamelCase__ :   str					):


       """simple docstring"""







       cls._set_token_in_kwargs(a_					)

       UpperCamelCase							, UpperCamelCase      							=    cls.get_config_dict(a_    ,		**a_					)

       # 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(a_    ,		**a_					)

class 					SCREAMING_SNAKE_CASE					(    _a						):






    """simple docstring"""





    _SCREAMING_SNAKE_CASE          =    """blip_vision_model"""






    def __init__(    self :   List[str]    ,		UpperCamelCase__ :   Optional[int]=7_6_8    ,		UpperCamelCase__ :   List[str]=3_0_7_2    ,		UpperCamelCase__ :   Tuple=5_1_2    ,		UpperCamelCase__ :   Dict=1_2    ,		UpperCamelCase__ :   Optional[int]=1_2    ,		UpperCamelCase__ :   int=3_8_4    ,		UpperCamelCase__ :   Union[str, Any]=1_6    ,		UpperCamelCase__ :   int="gelu"    ,		UpperCamelCase__ :   List[Any]=1E-5    ,		UpperCamelCase__ :   int=0.0    ,		UpperCamelCase__ :   List[Any]=1E-1_0    ,		**UpperCamelCase__ :   Any    ,		):


       """simple docstring"""







       super().__init__(**a_					)

       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 :   Optional[Any]    ,		UpperCamelCase__ :   Optional[int]    ,		**UpperCamelCase__ :   Tuple					):


       """simple docstring"""







       cls._set_token_in_kwargs(a_					)

       UpperCamelCase							, UpperCamelCase      							=    cls.get_config_dict(a_    ,		**a_					)

       # 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(a_    ,		**a_					)

class 					SCREAMING_SNAKE_CASE					(    _a						):






    """simple docstring"""





    _SCREAMING_SNAKE_CASE          =    """blip"""
    _SCREAMING_SNAKE_CASE          =    True






    def __init__(    self :   Optional[int]    ,		UpperCamelCase__ :   List[Any]=None    ,		UpperCamelCase__ :   int=None    ,		UpperCamelCase__ :   Union[str, Any]=5_1_2    ,		UpperCamelCase__ :   List[Any]=2.6_5_9_2    ,		UpperCamelCase__ :   int=2_5_6    ,		**UpperCamelCase__ :   Dict    ,		):


       """simple docstring"""







       super().__init__(**a_					)

       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(**a_					)
       UpperCamelCase      							=    BlipVisionConfig(**a_					)

       UpperCamelCase      							=    self.vision_config.hidden_size

       UpperCamelCase      							=    projection_dim
       UpperCamelCase      							=    logit_scale_init_value
       UpperCamelCase      							=    1.0
       UpperCamelCase      							=    0.0_2
       UpperCamelCase      							=    image_text_hidden_size






    @classmethod
    def 					A			(    cls :   Dict    ,		UpperCamelCase__ :   Tuple    ,		UpperCamelCase__ :   Any    ,		**UpperCamelCase__ :   List[Any]					):


       """simple docstring"""







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






    def 					A			(    self :   Union[str, Any]					):


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






import functools
import operator

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


_lowerCAmelCase	:   List[str]    =   logging.get_logger(__name__)

_lowerCAmelCase	:   Tuple    =   {
    "microsoft/wavlm-base": "https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json",
    # See all WavLM models at https://huggingface.co/models?filter=wavlm
}


class 	__snake_case   ( SCREAMING_SNAKE_CASE ):
		SCREAMING_SNAKE_CASE__								=	'wavlm'
		def __init__(							self    ,a_=32    ,a_=768    ,a_=12    ,a_=12    ,a_=3072    ,a_="gelu"    ,a_=0.1    ,a_=0.1    ,a_=0.1    ,a_=0.0    ,a_=0.1    ,a_=0.1    ,a_=0.02    ,a_=1e-5    ,a_="group"    ,a_="gelu"    ,a_=(512, 512, 512, 512, 512, 512, 512)    ,a_=(5, 2, 2, 2, 2, 2, 2)    ,a_=(10, 3, 3, 3, 3, 2, 2)    ,a_=False    ,a_=128    ,a_=16    ,a_=320    ,a_=800    ,a_=False    ,a_=True    ,a_=0.05    ,a_=10    ,a_=2    ,a_=0.0    ,a_=10    ,a_=320    ,a_=2    ,a_=0.1    ,a_=100    ,a_=256    ,a_=256    ,a_=0.1    ,a_="mean"    ,a_=False    ,a_=False    ,a_=256    ,a_=(512, 512, 512, 512, 1500)    ,a_=(5, 3, 3, 1, 1)    ,a_=(1, 2, 3, 1, 1)    ,a_=512    ,a_=80    ,a_=0    ,a_=1    ,a_=2    ,a_=False    ,a_=3    ,a_=2    ,a_=3    ,a_=None    ,**a_    ,):







						"""simple docstring"""
						super().__init__(**a_    ,pad_token_id=a_    ,bos_token_id=a_    ,eos_token_id=a_						)
						lowerCAmelCase__		  =  hidden_size
						lowerCAmelCase__		  =  feat_extract_norm
						lowerCAmelCase__		  =  feat_extract_activation
						lowerCAmelCase__		  =  list(a_						)
						lowerCAmelCase__		  =  list(a_						)
						lowerCAmelCase__		  =  list(a_						)
						lowerCAmelCase__		  =  conv_bias
						lowerCAmelCase__		  =  num_buckets
						lowerCAmelCase__		  =  max_bucket_distance
						lowerCAmelCase__		  =  num_conv_pos_embeddings
						lowerCAmelCase__		  =  num_conv_pos_embedding_groups
						lowerCAmelCase__		  =  len(self.conv_dim						)
						lowerCAmelCase__		  =  num_hidden_layers
						lowerCAmelCase__		  =  intermediate_size
						lowerCAmelCase__		  =  hidden_act
						lowerCAmelCase__		  =  num_attention_heads
						lowerCAmelCase__		  =  hidden_dropout
						lowerCAmelCase__		  =  attention_dropout
						lowerCAmelCase__		  =  activation_dropout
						lowerCAmelCase__		  =  feat_proj_dropout
						lowerCAmelCase__		  =  final_dropout
						lowerCAmelCase__		  =  layerdrop
						lowerCAmelCase__		  =  layer_norm_eps
						lowerCAmelCase__		  =  initializer_range
						lowerCAmelCase__		  =  num_ctc_classes
						lowerCAmelCase__		  =  vocab_size
						lowerCAmelCase__		  =  do_stable_layer_norm
						lowerCAmelCase__		  =  use_weighted_layer_sum
						lowerCAmelCase__		  =  classifier_proj_size

						if (
						    (len(self.conv_stride						) != self.num_feat_extract_layers)
						    or (len(self.conv_kernel						) != self.num_feat_extract_layers)
						    or (len(self.conv_dim						) != self.num_feat_extract_layers)
						):
										raise ValueError(
										    'Configuration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` =='
										    ' `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) ='
										    f' {len(self.conv_dim						)}`, `len(config.conv_stride) = {len(self.conv_stride						)}`,'
										    f' `len(config.conv_kernel) = {len(self.conv_kernel						)}`.'						)

						# fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
						lowerCAmelCase__		  =  apply_spec_augment
						lowerCAmelCase__		  =  mask_time_prob
						lowerCAmelCase__		  =  mask_time_length
						lowerCAmelCase__		  =  mask_time_min_masks
						lowerCAmelCase__		  =  mask_feature_prob
						lowerCAmelCase__		  =  mask_feature_length

						# parameters for pretraining with codevector quantized representations
						lowerCAmelCase__		  =  num_codevectors_per_group
						lowerCAmelCase__		  =  num_codevector_groups
						lowerCAmelCase__		  =  contrastive_logits_temperature
						lowerCAmelCase__		  =  num_negatives
						lowerCAmelCase__		  =  codevector_dim
						lowerCAmelCase__		  =  proj_codevector_dim
						lowerCAmelCase__		  =  diversity_loss_weight

						# ctc loss
						lowerCAmelCase__		  =  ctc_loss_reduction
						lowerCAmelCase__		  =  ctc_zero_infinity

						# adapter
						lowerCAmelCase__		  =  add_adapter
						lowerCAmelCase__		  =  adapter_kernel_size
						lowerCAmelCase__		  =  adapter_stride
						lowerCAmelCase__		  =  num_adapter_layers
						lowerCAmelCase__		  =  output_hidden_size or hidden_size

						# SequenceClassification-specific parameter. Feel free to ignore for other classes.
						lowerCAmelCase__		  =  classifier_proj_size

						# XVector-specific parameters. Feel free to ignore for other classes.
						lowerCAmelCase__		  =  list(a_						)
						lowerCAmelCase__		  =  list(a_						)
						lowerCAmelCase__		  =  list(a_						)
						lowerCAmelCase__		  =  xvector_output_dim



		@property
		def 						SCREAMING_SNAKE_CASE_					(							self						):







						"""simple docstring"""
						return functools.reduce(operator.mul    ,self.conv_stride    ,1						)
