




import copy
import os
from typing import Union

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


lowercase__				:      Optional[int]	   = logging.get_logger(__name__)

lowercase__				:      Optional[int]	   = {
    "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       a__	( UpperCamelCase__				):
     a		:      Optional[int]		 =     """bridgetower_vision_model"""







     def __init__(     self  ,		A=768  ,		A=12  ,		A=3  ,		A=16  ,		A=288  ,		A=1  ,		A=1e-05  ,		A=False  ,		A=True  ,		A=False  ,		**A  ,		)  ->   Optional[Any]:



          '''simple docstring'''



          super().__init__(**A			)
          a     =				hidden_size
          a     =				num_hidden_layers
          a     =				num_channels
          a     =				patch_size
          a     =				image_size
          a     =				initializer_factor
          a     =				layer_norm_eps
          a     =				stop_gradient
          a     =				share_layernorm
          a     =				remove_last_layer







     @classmethod
     def       lowerCAmelCase_    (     cls  ,		A  ,		**A			)  ->   "PretrainedConfig":



          '''simple docstring'''



          a  ,				a     =				cls.get_config_dict(A  ,		**A			)

          if config_dict.get("model_type"			) == "bridgetower":
               a     =				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       a__	( UpperCamelCase__				):
     a		:      List[Any]		 =     """bridgetower_text_model"""







     def __init__(     self  ,		A=50265  ,		A=768  ,		A=12  ,		A=12  ,		A=1  ,		A=3072  ,		A="gelu"  ,		A=0.1  ,		A=0.1  ,		A=514  ,		A=1  ,		A=1e-05  ,		A=1  ,		A=0  ,		A=2  ,		A="absolute"  ,		A=True  ,		**A  ,		)  ->   int:



          '''simple docstring'''



          super().__init__(**A			)

          a     =				vocab_size
          a     =				hidden_size
          a     =				num_hidden_layers
          a     =				num_attention_heads
          a     =				hidden_act
          a     =				initializer_factor
          a     =				intermediate_size
          a     =				hidden_dropout_prob
          a     =				attention_probs_dropout_prob
          a     =				max_position_embeddings
          a     =				type_vocab_size
          a     =				layer_norm_eps
          a     =				position_embedding_type
          a     =				use_cache
          a     =				pad_token_id
          a     =				bos_token_id
          a     =				eos_token_id







     @classmethod
     def       lowerCAmelCase_    (     cls  ,		A  ,		**A			)  ->   "PretrainedConfig":



          '''simple docstring'''



          a  ,				a     =				cls.get_config_dict(A  ,		**A			)

          if config_dict.get("model_type"			) == "bridgetower":
               a     =				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       a__	( UpperCamelCase__				):
     a		:      str		 =     """bridgetower"""







     def __init__(     self  ,		A=True  ,		A="gelu"  ,		A=768  ,		A=1  ,		A=1e-05  ,		A=False  ,		A="add"  ,		A=12  ,		A=6  ,		A=False  ,		A=False  ,		A=None  ,		A=None  ,		**A  ,		)  ->   Dict:



          '''simple docstring'''



          a     =				kwargs.pop("text_config_dict"  ,		A			)
          a     =				kwargs.pop("vision_config_dict"  ,		A			)

          super().__init__(**A			)
          a     =				share_cross_modal_transformer_layers
          a     =				hidden_act
          a     =				hidden_size
          a     =				initializer_factor
          a     =				layer_norm_eps
          a     =				share_link_tower_layers
          a     =				link_tower_type
          a     =				num_attention_heads
          a     =				num_hidden_layers
          a     =				tie_word_embeddings
          a     =				init_layernorm_from_vision_encoder

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

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

          a     =				BridgeTowerTextConfig(**A			)
          a     =				BridgeTowerVisionConfig(**A			)







     @classmethod
     def       lowerCAmelCase_    (     cls  ,		A  ,		A  ,		**A			)  ->   str:



          '''simple docstring'''



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







     def       lowerCAmelCase_    (     self			)  ->   List[Any]:



          '''simple docstring'''



          a     =				copy.deepcopy(self.__dict__			)
          a     =				self.text_config.to_dict()
          a     =				self.vision_config.to_dict()
          a     =				self.__class__.model_type
          return output







import functools
import operator

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


lowercase__				:      Any	   = logging.get_logger(__name__)

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




class       a__	( UpperCamelCase__				):
     a		:      Optional[Any]		 =     """sew-d"""







     def __init__(     self  ,		A=32  ,		A=768  ,		A=12  ,		A=12  ,		A=3072  ,		A=2  ,		A=512  ,		A=256  ,		A=True  ,		A=True  ,		A=("p2c", "c2p")  ,		A="layer_norm"  ,		A="gelu_python"  ,		A=0.1  ,		A=0.1  ,		A=0.1  ,		A=0.0  ,		A=0.1  ,		A=0.0_2  ,		A=1e-7  ,		A=1e-5  ,		A="group"  ,		A="gelu"  ,		A=(64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512)  ,		A=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)  ,		A=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)  ,		A=False  ,		A=128  ,		A=16  ,		A=True  ,		A=0.0_5  ,		A=10  ,		A=2  ,		A=0.0  ,		A=10  ,		A=0  ,		A="mean"  ,		A=False  ,		A=False  ,		A=256  ,		A=0  ,		A=1  ,		A=2  ,		**A  ,		)  ->   Dict:



          '''simple docstring'''



          super().__init__(**A  ,		pad_token_id=A  ,		bos_token_id=A  ,		eos_token_id=A			)
          a     =				hidden_size
          a     =				feat_extract_norm
          a     =				feat_extract_activation
          a     =				list(A			)
          a     =				list(A			)
          a     =				list(A			)
          a     =				conv_bias
          a     =				num_conv_pos_embeddings
          a     =				num_conv_pos_embedding_groups
          a     =				len(self.conv_dim			)
          a     =				num_hidden_layers
          a     =				intermediate_size
          a     =				squeeze_factor
          a     =				max_position_embeddings
          a     =				position_buckets
          a     =				share_att_key
          a     =				relative_attention
          a     =				norm_rel_ebd
          a     =				list(A			)
          a     =				hidden_act
          a     =				num_attention_heads
          a     =				hidden_dropout
          a     =				attention_dropout
          a     =				activation_dropout
          a     =				feat_proj_dropout
          a     =				final_dropout
          a     =				layer_norm_eps
          a     =				feature_layer_norm_eps
          a     =				initializer_range
          a     =				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
          a     =				apply_spec_augment
          a     =				mask_time_prob
          a     =				mask_time_length
          a     =				mask_time_min_masks
          a     =				mask_feature_prob
          a     =				mask_feature_length
          a     =				mask_feature_min_masks

          # ctc loss
          a     =				ctc_loss_reduction
          a     =				ctc_zero_infinity

          # sequence classification
          a     =				use_weighted_layer_sum
          a     =				classifier_proj_size







     @property
     def       lowerCAmelCase_    (     self			)  ->   List[str]:



          '''simple docstring'''



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

