"""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_     =	{
    '''BridgeTower/bridgetower-base''': '''https://huggingface.co/BridgeTower/bridgetower-base/blob/main/config.json''',
    '''BridgeTower/bridgetower-base-itm-mlm''': (
        '''https://huggingface.co/BridgeTower/bridgetower-base-itm-mlm/blob/main/config.json'''
    ),
}




class  _snake_case		(    __snake_case ):







				"""simple docstring"""






				a			=						"bridgetower_vision_model"





				def __init__(      self							:							Union[str, Any]      ,    _A							:							Union[str, Any]=7_6_8      ,    _A							:							Tuple=1_2      ,    _A							:							List[Any]=3      ,    _A							:							Dict=1_6      ,    _A							:							str=2_8_8      ,    _A							:							Optional[Any]=1      ,    _A							:							Union[str, Any]=1e-05      ,    _A							:							Any=False      ,    _A							:							int=True      ,    _A							:							Optional[int]=False      ,    **_A							:							int      ,    ):



											"""simple docstring"""







											super().__init__(**_A)
											_SCREAMING_SNAKE_CASE		:						int			  =    hidden_size
											_SCREAMING_SNAKE_CASE		:						int			  =    num_hidden_layers
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    num_channels
											_SCREAMING_SNAKE_CASE		:						str			  =    patch_size
											_SCREAMING_SNAKE_CASE		:						int			  =    image_size
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    initializer_factor
											_SCREAMING_SNAKE_CASE		:						str			  =    layer_norm_eps
											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    stop_gradient
											_SCREAMING_SNAKE_CASE		:						Any			  =    share_layernorm
											_SCREAMING_SNAKE_CASE		:						int			  =    remove_last_layer





				@classmethod
				def 		_lowerCAmelCase		(      cls							:							Optional[int]      ,    _A							:							Union[str, os.PathLike]      ,    **_A							:							Union[str, Any]):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE  ,				_SCREAMING_SNAKE_CASE		:						Any			  =    cls.get_config_dict(_A      ,    **_A)

											if config_dict.get("""model_type""") == "bridgetower":
																		_SCREAMING_SNAKE_CASE		:						List[str]			  =    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  _snake_case		(    __snake_case ):







				"""simple docstring"""






				a			=						"bridgetower_text_model"





				def __init__(      self							:							Any      ,    _A							:							int=5_0_2_6_5      ,    _A							:							Union[str, Any]=7_6_8      ,    _A							:							int=1_2      ,    _A							:							Tuple=1_2      ,    _A							:							Any=1      ,    _A							:							List[Any]=3_0_7_2      ,    _A							:							str="gelu"      ,    _A							:							List[Any]=0.1      ,    _A							:							Union[str, Any]=0.1      ,    _A							:							List[str]=5_1_4      ,    _A							:							Union[str, Any]=1      ,    _A							:							str=1e-05      ,    _A							:							Dict=1      ,    _A							:							Union[str, Any]=0      ,    _A							:							Any=2      ,    _A							:							Dict="absolute"      ,    _A							:							Dict=True      ,    **_A							:							Any      ,    ):



											"""simple docstring"""







											super().__init__(**_A)

											_SCREAMING_SNAKE_CASE		:						int			  =    vocab_size
											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    hidden_size
											_SCREAMING_SNAKE_CASE		:						Any			  =    num_hidden_layers
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    num_attention_heads
											_SCREAMING_SNAKE_CASE		:						int			  =    hidden_act
											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    initializer_factor
											_SCREAMING_SNAKE_CASE		:						str			  =    intermediate_size
											_SCREAMING_SNAKE_CASE		:						Any			  =    hidden_dropout_prob
											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    attention_probs_dropout_prob
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    max_position_embeddings
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    type_vocab_size
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    layer_norm_eps
											_SCREAMING_SNAKE_CASE		:						Any			  =    position_embedding_type
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    use_cache
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    pad_token_id
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    bos_token_id
											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    eos_token_id





				@classmethod
				def 		_lowerCAmelCase		(      cls							:							int      ,    _A							:							Union[str, os.PathLike]      ,    **_A							:							Tuple):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE  ,				_SCREAMING_SNAKE_CASE		:						Tuple			  =    cls.get_config_dict(_A      ,    **_A)

											if config_dict.get("""model_type""") == "bridgetower":
																		_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(_A      ,    **_A)




class  _snake_case		(    __snake_case ):







				"""simple docstring"""






				a			=						"bridgetower"





				def __init__(      self							:							List[str]      ,    _A							:							str=True      ,    _A							:							Tuple="gelu"      ,    _A							:							Optional[Any]=7_6_8      ,    _A							:							Dict=1      ,    _A							:							Tuple=1e-05      ,    _A							:							Dict=False      ,    _A							:							Tuple="add"      ,    _A							:							Tuple=1_2      ,    _A							:							Any=6      ,    _A							:							Union[str, Any]=False      ,    _A							:							Dict=False      ,    _A							:							str=None      ,    _A							:							Optional[Any]=None      ,    **_A							:							Optional[int]      ,    ):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						str			  =    kwargs.pop("""text_config_dict"""      ,    _A)
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    kwargs.pop("""vision_config_dict"""      ,    _A)

											super().__init__(**_A)
											_SCREAMING_SNAKE_CASE		:						str			  =    share_cross_modal_transformer_layers
											_SCREAMING_SNAKE_CASE		:						int			  =    hidden_act
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    hidden_size
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    initializer_factor
											_SCREAMING_SNAKE_CASE		:						str			  =    layer_norm_eps
											_SCREAMING_SNAKE_CASE		:						Dict			  =    share_link_tower_layers
											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    link_tower_type
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    num_attention_heads
											_SCREAMING_SNAKE_CASE		:						Dict			  =    num_hidden_layers
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    tie_word_embeddings
											_SCREAMING_SNAKE_CASE		:						Any			  =    init_layernorm_from_vision_encoder

											if text_config is None:
																		_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    {}
																		logger.info("""`text_config` is `None`. Initializing the `BridgeTowerTextConfig` with default values.""")

											if vision_config is None:
																		_SCREAMING_SNAKE_CASE		:						Tuple			  =    {}
																		logger.info("""`vision_config` is `None`. Initializing the `BridgeTowerVisionConfig` with default values.""")

											_SCREAMING_SNAKE_CASE		:						Optional[Any]			  =    BridgeTowerTextConfig(**_A)
											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    BridgeTowerVisionConfig(**_A)





				@classmethod
				def 		_lowerCAmelCase		(      cls							:							str      ,    _A							:							BridgeTowerTextConfig      ,    _A							:							BridgeTowerVisionConfig      ,    **_A							:							Union[str, Any]):



											"""simple docstring"""







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





				def 		_lowerCAmelCase		(      self							:							List[Any]):



											"""simple docstring"""







											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    copy.deepcopy(self.__dict__)
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    self.text_config.to_dict()
											_SCREAMING_SNAKE_CASE		:						Dict			  =    self.vision_config.to_dict()
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    self.__class__.model_type
											return output



"""simple docstring"""





import functools
import operator

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


lowerCAmelCase_     =	logging.get_logger(__name__)

lowerCAmelCase_     =	{
    '''asapp/sew-tiny-100k''': '''https://huggingface.co/asapp/sew-tiny-100k/resolve/main/config.json''',
    # See all SEW models at https://huggingface.co/models?filter=sew
}




class  _snake_case		(    __snake_case ):







				"""simple docstring"""






				a			=						"sew"





				def __init__(      self							:							List[Any]      ,    _A							:							Tuple=3_2      ,    _A							:							str=7_6_8      ,    _A							:							Dict=1_2      ,    _A							:							Tuple=1_2      ,    _A							:							Optional[Any]=3_0_7_2      ,    _A							:							List[str]=2      ,    _A							:							Dict="gelu"      ,    _A							:							Union[str, Any]=0.1      ,    _A							:							Optional[int]=0.1      ,    _A							:							Optional[int]=0.1      ,    _A							:							Optional[int]=0.0      ,    _A							:							str=0.1      ,    _A							:							Tuple=0.1      ,    _A							:							Optional[int]=0.02      ,    _A							:							Dict=1e-5      ,    _A							:							str="group"      ,    _A							:							Tuple="gelu"      ,    _A							:							Union[str, Any]=(6_4, 1_2_8, 1_2_8, 1_2_8, 1_2_8, 2_5_6, 2_5_6, 2_5_6, 2_5_6, 5_1_2, 5_1_2, 5_1_2, 5_1_2)      ,    _A							:							Optional[Any]=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)      ,    _A							:							Any=(1_0, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)      ,    _A							:							Tuple=False      ,    _A							:							Tuple=1_2_8      ,    _A							:							int=1_6      ,    _A							:							Union[str, Any]=True      ,    _A							:							Optional[Any]=0.05      ,    _A							:							List[Any]=1_0      ,    _A							:							Union[str, Any]=2      ,    _A							:							Tuple=0.0      ,    _A							:							Union[str, Any]=1_0      ,    _A							:							Optional[int]=0      ,    _A							:							Union[str, Any]="mean"      ,    _A							:							Optional[int]=False      ,    _A							:							List[Any]=False      ,    _A							:							int=2_5_6      ,    _A							:							str=0      ,    _A							:							Optional[int]=1      ,    _A							:							List[Any]=2      ,    **_A							:							Dict      ,    ):



											"""simple docstring"""







											super().__init__(**_A      ,    pad_token_id=_A      ,    bos_token_id=_A      ,    eos_token_id=_A)
											_SCREAMING_SNAKE_CASE		:						str			  =    hidden_size
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    feat_extract_norm
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    feat_extract_activation
											_SCREAMING_SNAKE_CASE		:						Dict			  =    list(_A)
											_SCREAMING_SNAKE_CASE		:						int			  =    list(_A)
											_SCREAMING_SNAKE_CASE		:						int			  =    list(_A)
											_SCREAMING_SNAKE_CASE		:						str			  =    conv_bias
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    num_conv_pos_embeddings
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    num_conv_pos_embedding_groups
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    len(self.conv_dim)
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    num_hidden_layers
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    intermediate_size
											_SCREAMING_SNAKE_CASE		:						str			  =    squeeze_factor
											_SCREAMING_SNAKE_CASE		:						Dict			  =    hidden_act
											_SCREAMING_SNAKE_CASE		:						str			  =    num_attention_heads
											_SCREAMING_SNAKE_CASE		:						Dict			  =    hidden_dropout
											_SCREAMING_SNAKE_CASE		:						Tuple			  =    attention_dropout
											_SCREAMING_SNAKE_CASE		:						int			  =    activation_dropout
											_SCREAMING_SNAKE_CASE		:						Any			  =    feat_proj_dropout
											_SCREAMING_SNAKE_CASE		:						str			  =    final_dropout
											_SCREAMING_SNAKE_CASE		:						Union[str, Any]			  =    layerdrop
											_SCREAMING_SNAKE_CASE		:						Any			  =    layer_norm_eps
											_SCREAMING_SNAKE_CASE		:						int			  =    initializer_range
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    vocab_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)`,"""
																		    f"""but is `len(config.conv_dim) = {len(self.conv_dim)}`, `len(config.conv_stride)"""
																		    f"""= {len(self.conv_stride)}`, `len(config.conv_kernel) = {len(self.conv_kernel)}`.""")

											# fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    apply_spec_augment
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    mask_time_prob
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    mask_time_length
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    mask_time_min_masks
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    mask_feature_prob
											_SCREAMING_SNAKE_CASE		:						int			  =    mask_feature_length
											_SCREAMING_SNAKE_CASE		:						List[Any]			  =    mask_feature_min_masks

											# ctc loss
											_SCREAMING_SNAKE_CASE		:						int			  =    ctc_loss_reduction
											_SCREAMING_SNAKE_CASE		:						Optional[int]			  =    ctc_zero_infinity

											# sequence classification
											_SCREAMING_SNAKE_CASE		:						Dict			  =    use_weighted_layer_sum
											_SCREAMING_SNAKE_CASE		:						List[str]			  =    classifier_proj_size





				@property
				def 		_lowerCAmelCase		(      self							:							Any):



											"""simple docstring"""







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


