






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__ (				lowercase_):

       '''simple docstring'''
       lowerCamelCase				:					str								=			"bridgetower_vision_model"



       def __init__(				self      ,    a__=7_68      ,    a__=12      ,    a__=3      ,    a__=16      ,    a__=2_88      ,    a__=1      ,    a__=1e-05      ,    a__=False      ,    a__=True      ,    a__=False      ,    **a__      ,    )			->   str:






            '''simple docstring'''





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



       @classmethod
       def        __lowercase    (				cls      ,    a__      ,    **a__     )			->   "PretrainedConfig":






            '''simple docstring'''





            __snake_case							,			__snake_case      :Union[str, Any] 							=    cls.get_config_dict(a__      ,    **a__     )

            if config_dict.get("""model_type"""     ) == "bridgetower":
                 __snake_case      :Union[str, 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__ (				lowercase_):

       '''simple docstring'''
       lowerCamelCase				:					Optional[int]								=			"bridgetower_text_model"



       def __init__(				self      ,    a__=5_02_65      ,    a__=7_68      ,    a__=12      ,    a__=12      ,    a__=1      ,    a__=30_72      ,    a__="gelu"      ,    a__=0.1      ,    a__=0.1      ,    a__=5_14      ,    a__=1      ,    a__=1e-05      ,    a__=1      ,    a__=0      ,    a__=2      ,    a__="absolute"      ,    a__=True      ,    **a__      ,    )			->   List[str]:






            '''simple docstring'''





            super().__init__(**a__     )

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



       @classmethod
       def        __lowercase    (				cls      ,    a__      ,    **a__     )			->   "PretrainedConfig":






            '''simple docstring'''





            __snake_case							,			__snake_case      :List[str] 							=    cls.get_config_dict(a__      ,    **a__     )

            if config_dict.get("""model_type"""     ) == "bridgetower":
                 __snake_case      :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__ (				lowercase_):

       '''simple docstring'''
       lowerCamelCase				:					List[Any]								=			"bridgetower"



       def __init__(				self      ,    a__=True      ,    a__="gelu"      ,    a__=7_68      ,    a__=1      ,    a__=1e-05      ,    a__=False      ,    a__="add"      ,    a__=12      ,    a__=6      ,    a__=False      ,    a__=False      ,    a__=None      ,    a__=None      ,    **a__      ,    )			->   int:






            '''simple docstring'''





            __snake_case      :int 							=    kwargs.pop("""text_config_dict"""      ,    a__     )
            __snake_case      :Union[str, Any] 							=    kwargs.pop("""vision_config_dict"""      ,    a__     )

            super().__init__(**a__     )
            __snake_case      :Optional[Any] 							=    share_cross_modal_transformer_layers
            __snake_case      :Optional[Any] 							=    hidden_act
            __snake_case      :List[str] 							=    hidden_size
            __snake_case      :str 							=    initializer_factor
            __snake_case      :Optional[int] 							=    layer_norm_eps
            __snake_case      :Any 							=    share_link_tower_layers
            __snake_case      :Any 							=    link_tower_type
            __snake_case      :Tuple 							=    num_attention_heads
            __snake_case      :str 							=    num_hidden_layers
            __snake_case      :Any 							=    tie_word_embeddings
            __snake_case      :Optional[int] 							=    init_layernorm_from_vision_encoder

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

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

            __snake_case      :Dict 							=    BridgeTowerTextConfig(**a__     )
            __snake_case      :str 							=    BridgeTowerVisionConfig(**a__     )



       @classmethod
       def        __lowercase    (				cls      ,    a__      ,    a__      ,    **a__     )			->   Union[str, Any]:






            '''simple docstring'''





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



       def        __lowercase    (				self     )			->   Optional[int]:






            '''simple docstring'''





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










from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


lowerCamelCase__       		=  logging.get_logger(__name__)

lowerCamelCase__       		=  {
    """microsoft/focalnet-tiny""": """https://huggingface.co/microsoft/focalnet-tiny/resolve/main/config.json""",
}




class       snake_case__ (				lowercase_						,     lowercase_):

       '''simple docstring'''
       lowerCamelCase				:					List[Any]								=			"focalnet"



       def __init__(				self      ,    a__=2_24      ,    a__=4      ,    a__=3      ,    a__=96      ,    a__=False      ,    a__=[1_92, 3_84, 7_68, 7_68]      ,    a__=[2, 2, 6, 2]      ,    a__=[2, 2, 2, 2]      ,    a__=[3, 3, 3, 3]      ,    a__="gelu"      ,    a__=4.0      ,    a__=0.0      ,    a__=0.1      ,    a__=False      ,    a__=1e-4      ,    a__=False      ,    a__=False      ,    a__=False      ,    a__=0.02      ,    a__=1e-5      ,    a__=32      ,    a__=None      ,    a__=None      ,    **a__      ,    )			->   Tuple:






            '''simple docstring'''





            super().__init__(**a__     )

            __snake_case      :Optional[Any] 							=    image_size
            __snake_case      :Dict 							=    patch_size
            __snake_case      :Tuple 							=    num_channels
            __snake_case      :List[str] 							=    embed_dim
            __snake_case      :Any 							=    use_conv_embed
            __snake_case      :List[Any] 							=    hidden_sizes
            __snake_case      :str 							=    depths
            __snake_case      :List[Any] 							=    focal_levels
            __snake_case      :int 							=    focal_windows
            __snake_case      :Any 							=    hidden_act
            __snake_case      :List[str] 							=    mlp_ratio
            __snake_case      :str 							=    hidden_dropout_prob
            __snake_case      :List[str] 							=    drop_path_rate
            __snake_case      :int 							=    use_layerscale
            __snake_case      :int 							=    layerscale_value
            __snake_case      :Tuple 							=    use_post_layernorm
            __snake_case      :Dict 							=    use_post_layernorm_in_modulation
            __snake_case      :Union[str, Any] 							=    normalize_modulator
            __snake_case      :List[str] 							=    initializer_range
            __snake_case      :Optional[Any] 							=    layer_norm_eps
            __snake_case      :Tuple 							=    encoder_stride
            __snake_case      :List[str] 							=    ["""stem"""] + [F'''stage{idx}''' for idx in range(1      ,    len(self.depths     ) + 1     )]
            __snake_case							,			__snake_case      :str 							=    get_aligned_output_features_output_indices(
                out_features=a__      ,    out_indices=a__      ,    stage_names=self.stage_names     )


