


'''simple docstring'''






import copy
import os
from typing import Union

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


lowercase							=logging.get_logger(__name__)

lowercase							={
    '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  __magic_name__							(		__SCREAMING_SNAKE_CASE    ):
       UpperCAmelCase										="bridgetower_vision_model"






       def __init__(      self  ,							snake_case=7_6_8  ,							snake_case=1_2  ,							snake_case=3  ,							snake_case=1_6  ,							snake_case=2_8_8  ,							snake_case=1  ,							snake_case=1E-0_5  ,							snake_case=False  ,							snake_case=True  ,							snake_case=False  ,							**snake_case  ,							)						->  Any:




          '''simple docstring'''
          super().__init__(**_SCREAMING_SNAKE_CASE)
          _UpperCAmelCase       :       Tuple							   =hidden_size
          _UpperCAmelCase       :       int							   =num_hidden_layers
          _UpperCAmelCase       :       List[Any]							   =num_channels
          _UpperCAmelCase       :       Tuple							   =patch_size
          _UpperCAmelCase       :       Tuple							   =image_size
          _UpperCAmelCase       :       Optional[Any]							   =initializer_factor
          _UpperCAmelCase       :       Union[str, Any]							   =layer_norm_eps
          _UpperCAmelCase       :       Dict							   =stop_gradient
          _UpperCAmelCase       :       Any							   =share_layernorm
          _UpperCAmelCase       :       Optional[int]							   =remove_last_layer






       @classmethod
       def       lowerCAmelCase		(      cls  ,							snake_case  ,							**snake_case)						->  "PretrainedConfig":




          '''simple docstring'''
          _UpperCAmelCase       :       Optional[int]							   =cls.get_config_dict(_SCREAMING_SNAKE_CASE  ,							**_SCREAMING_SNAKE_CASE)

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






class  __magic_name__							(		__SCREAMING_SNAKE_CASE    ):
       UpperCAmelCase										="bridgetower_text_model"






       def __init__(      self  ,							snake_case=5_0_2_6_5  ,							snake_case=7_6_8  ,							snake_case=1_2  ,							snake_case=1_2  ,							snake_case=1  ,							snake_case=3_0_7_2  ,							snake_case="gelu"  ,							snake_case=0.1  ,							snake_case=0.1  ,							snake_case=5_1_4  ,							snake_case=1  ,							snake_case=1E-0_5  ,							snake_case=1  ,							snake_case=0  ,							snake_case=2  ,							snake_case="absolute"  ,							snake_case=True  ,							**snake_case  ,							)						->  Optional[int]:




          '''simple docstring'''
          super().__init__(**_SCREAMING_SNAKE_CASE)

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






       @classmethod
       def       lowerCAmelCase		(      cls  ,							snake_case  ,							**snake_case)						->  "PretrainedConfig":




          '''simple docstring'''
          _UpperCAmelCase       :       List[Any]							   =cls.get_config_dict(_SCREAMING_SNAKE_CASE  ,							**_SCREAMING_SNAKE_CASE)

          if config_dict.get('model_type') == "bridgetower":
             _UpperCAmelCase       :       Optional[int]							   =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(_SCREAMING_SNAKE_CASE  ,							**_SCREAMING_SNAKE_CASE)






class  __magic_name__							(		__SCREAMING_SNAKE_CASE    ):
       UpperCAmelCase										="bridgetower"






       def __init__(      self  ,							snake_case=True  ,							snake_case="gelu"  ,							snake_case=7_6_8  ,							snake_case=1  ,							snake_case=1E-0_5  ,							snake_case=False  ,							snake_case="add"  ,							snake_case=1_2  ,							snake_case=6  ,							snake_case=False  ,							snake_case=False  ,							snake_case=None  ,							snake_case=None  ,							**snake_case  ,							)						->  Optional[int]:




          '''simple docstring'''
          _UpperCAmelCase       :       Union[str, Any]							   =kwargs.pop('text_config_dict'  ,							_SCREAMING_SNAKE_CASE)
          _UpperCAmelCase       :       int							   =kwargs.pop('vision_config_dict'  ,							_SCREAMING_SNAKE_CASE)

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

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

          if vision_config is None:
             _UpperCAmelCase       :       Union[str, Any]							   ={}
             logger.info('`vision_config` is `None`. Initializing the `BridgeTowerVisionConfig` with default values.')

          _UpperCAmelCase       :       str							   =BridgeTowerTextConfig(**_SCREAMING_SNAKE_CASE)
          _UpperCAmelCase       :       Any							   =BridgeTowerVisionConfig(**_SCREAMING_SNAKE_CASE)






       @classmethod
       def       lowerCAmelCase		(      cls  ,							snake_case  ,							snake_case  ,							**snake_case)						->  str:




          '''simple docstring'''
          return cls(text_config=text_config.to_dict()  ,							vision_config=vision_config.to_dict()  ,							**_SCREAMING_SNAKE_CASE)






       def       lowerCAmelCase		(      self)						->  Union[str, Any]:




          '''simple docstring'''
          _UpperCAmelCase       :       List[str]							   =copy.deepcopy(self.__dict__)
          _UpperCAmelCase       :       int							   =self.text_config.to_dict()
          _UpperCAmelCase       :       Tuple							   =self.vision_config.to_dict()
          _UpperCAmelCase       :       Tuple							   =self.__class__.model_type
          return output





'''simple docstring'''






import jax.numpy as jnp

from ...utils import logging
from ..ta.modeling_flax_ta import FlaxTaEncoderModel, FlaxTaForConditionalGeneration, FlaxTaModel
from .configuration_mta import MTaConfig


lowercase							=logging.get_logger(__name__)

lowercase							='T5Config'





def lowerCamelCase__      (						__lowerCamelCase	:							jnp.array	,   __lowerCamelCase	:							int	,   __lowerCamelCase	:							int							):







   '''simple docstring'''




   _UpperCAmelCase       :       List[Any]							   =jnp.zeros_like(__lowerCamelCase							)
   _UpperCAmelCase       :       Union[str, Any]							   =shifted_input_ids.at[:, 1:].set(input_ids[:, :-1]							)
   _UpperCAmelCase       :       List[Any]							   =shifted_input_ids.at[:, 0].set(__lowerCamelCase							)

   _UpperCAmelCase       :       str							   =jnp.where(shifted_input_ids == -1_0_0	,   __lowerCamelCase	,   __lowerCamelCase							)
   return shifted_input_ids






class  __magic_name__							(		lowerCAmelCase    ):
       UpperCAmelCase										="mt5"
       UpperCAmelCase										=MTaConfig






class  __magic_name__							(		lowerCAmelCase    ):
       UpperCAmelCase										="mt5"
       UpperCAmelCase										=MTaConfig






class  __magic_name__							(		lowerCAmelCase    ):
       UpperCAmelCase										="mt5"
       UpperCAmelCase										=MTaConfig

