

import copy
import os
from typing import TYPE_CHECKING, List, Union


if TYPE_CHECKING:
 pass

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


_UpperCamelCase					     =						logging.get_logger(__name__)

_UpperCamelCase					     =						{
    "kakaobrain/align-base": "https://huggingface.co/kakaobrain/align-base/resolve/main/config.json",
}







class     __lowercase (lowerCAmelCase_					):
 _UpperCamelCase         =    """align_text_model"""
 def __init__(				self ,				A_=3_0522 ,				A_=768 ,				A_=12 ,				A_=12 ,				A_=3072 ,				A_="gelu" ,				A_=0.1 ,				A_=0.1 ,				A_=512 ,				A_=2 ,				A_=0.02 ,				A_=1e-12 ,				A_=0 ,				A_="absolute" ,				A_=True ,				**A_ ,				)   ->Optional[int]:



       '''simple docstring'''





       super().__init__(**__lowerCamelCase   )

       __lowerCAmelCase   :		Optional[int]   =   vocab_size
       __lowerCAmelCase   :		List[Any]   =   hidden_size
       __lowerCAmelCase   :		str   =   num_hidden_layers
       __lowerCAmelCase   :		List[str]   =   num_attention_heads
       __lowerCAmelCase   :		Any   =   hidden_act
       __lowerCAmelCase   :		Optional[Any]   =   intermediate_size
       __lowerCAmelCase   :		Tuple   =   hidden_dropout_prob
       __lowerCAmelCase   :		Union[str, Any]   =   attention_probs_dropout_prob
       __lowerCAmelCase   :		Union[str, Any]   =   max_position_embeddings
       __lowerCAmelCase   :		Tuple   =   type_vocab_size
       __lowerCAmelCase   :		List[Any]   =   initializer_range
       __lowerCAmelCase   :		Optional[int]   =   layer_norm_eps
       __lowerCAmelCase   :		List[Any]   =   position_embedding_type
       __lowerCAmelCase   :		Optional[int]   =   use_cache
       __lowerCAmelCase   :		Tuple   =   pad_token_id





 @classmethod
 def       UpperCamelCase__    (				cls ,				A_ ,				**A_   )   ->Optional[int]:



       '''simple docstring'''





       cls._set_token_in_kwargs(__lowerCamelCase   )

       __lowerCAmelCase   :		str   =   cls.get_config_dict(__lowerCamelCase ,				**__lowerCamelCase   )

       # get the text config dict if we are loading from AlignConfig
       if config_dict.get('''model_type'''   ) == "align":
             __lowerCAmelCase   :		Tuple   =   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(__lowerCamelCase ,				**__lowerCamelCase   )







class     __lowercase (lowerCAmelCase_					):
 _UpperCamelCase         =    """align_vision_model"""
 def __init__(				self ,				A_ = 3 ,				A_ = 600 ,				A_ = 2.0 ,				A_ = 3.1 ,				A_ = 8 ,				A_ = [3, 3, 5, 3, 5, 5, 3] ,				A_ = [32, 16, 24, 40, 80, 112, 192] ,				A_ = [16, 24, 40, 80, 112, 192, 320] ,				A_ = [] ,				A_ = [1, 2, 2, 2, 1, 2, 1] ,				A_ = [1, 2, 2, 3, 3, 4, 1] ,				A_ = [1, 6, 6, 6, 6, 6, 6] ,				A_ = 0.25 ,				A_ = "swish" ,				A_ = 2560 ,				A_ = "mean" ,				A_ = 0.02 ,				A_ = 0.001 ,				A_ = 0.99 ,				A_ = 0.2 ,				**A_ ,				)   ->Optional[Any]:



       '''simple docstring'''





       super().__init__(**__lowerCamelCase   )

       __lowerCAmelCase   :		Optional[Any]   =   num_channels
       __lowerCAmelCase   :		List[Any]   =   image_size
       __lowerCAmelCase   :		Union[str, Any]   =   width_coefficient
       __lowerCAmelCase   :		Optional[Any]   =   depth_coefficient
       __lowerCAmelCase   :		Dict   =   depth_divisor
       __lowerCAmelCase   :		List[Any]   =   kernel_sizes
       __lowerCAmelCase   :		int   =   in_channels
       __lowerCAmelCase   :		List[Any]   =   out_channels
       __lowerCAmelCase   :		List[Any]   =   depthwise_padding
       __lowerCAmelCase   :		Tuple   =   strides
       __lowerCAmelCase   :		List[Any]   =   num_block_repeats
       __lowerCAmelCase   :		Optional[Any]   =   expand_ratios
       __lowerCAmelCase   :		str   =   squeeze_expansion_ratio
       __lowerCAmelCase   :		List[Any]   =   hidden_act
       __lowerCAmelCase   :		Dict   =   hidden_dim
       __lowerCAmelCase   :		Optional[Any]   =   pooling_type
       __lowerCAmelCase   :		List[str]   =   initializer_range
       __lowerCAmelCase   :		Optional[Any]   =   batch_norm_eps
       __lowerCAmelCase   :		Tuple   =   batch_norm_momentum
       __lowerCAmelCase   :		Dict   =   drop_connect_rate
       __lowerCAmelCase   :		Union[str, Any]   =   sum(__lowerCamelCase   ) * 4





 @classmethod
 def       UpperCamelCase__    (				cls ,				A_ ,				**A_   )   ->Optional[int]:



       '''simple docstring'''





       cls._set_token_in_kwargs(__lowerCamelCase   )

       __lowerCAmelCase   :		Union[str, Any]   =   cls.get_config_dict(__lowerCamelCase ,				**__lowerCamelCase   )

       # get the vision config dict if we are loading from AlignConfig
       if config_dict.get('''model_type'''   ) == "align":
             __lowerCAmelCase   :		int   =   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(__lowerCamelCase ,				**__lowerCamelCase   )







class     __lowercase (lowerCAmelCase_					):
 _UpperCamelCase         =    """align"""
 _UpperCamelCase         =    True
 def __init__(				self ,				A_=None ,				A_=None ,				A_=640 ,				A_=1.0 ,				A_=0.02 ,				**A_ ,				)   ->int:



       '''simple docstring'''





       super().__init__(**__lowerCamelCase   )

       if text_config is None:
             __lowerCAmelCase   :		Optional[Any]   =   {}
             logger.info('''text_config is None. Initializing the AlignTextConfig with default values.'''   )

       if vision_config is None:
             __lowerCAmelCase   :		str   =   {}
             logger.info('''vision_config is None. Initializing the AlignVisionConfig with default values.'''   )

       __lowerCAmelCase   :		Any   =   AlignTextConfig(**__lowerCamelCase   )
       __lowerCAmelCase   :		Optional[int]   =   AlignVisionConfig(**__lowerCamelCase   )

       __lowerCAmelCase   :		List[Any]   =   projection_dim
       __lowerCAmelCase   :		Optional[Any]   =   temperature_init_value
       __lowerCAmelCase   :		Optional[int]   =   initializer_range
 @classmethod
 def       UpperCamelCase__    (				cls ,				A_ ,				A_ ,				**A_   )   ->int:



       '''simple docstring'''





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





 def       UpperCamelCase__    (				self   )   ->Any:



       '''simple docstring'''





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








'''simple docstring'''






from ..utils import DummyObject, requires_backends






class        lowercase_      (						metaclass=lowerCAmelCase_							):
     A_											=			["flax"]





     def __init__(     self     :					Optional[Any]     ,							*__lowerCamelCase     :					Tuple     ,							**__lowerCamelCase     :					Optional[int]			):
           requires_backends(self     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Tuple     ,							*__lowerCamelCase     :					str     ,							**__lowerCamelCase     :					Optional[int]			):
           requires_backends(cls     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Any     ,							*__lowerCamelCase     :					Dict     ,							**__lowerCamelCase     :					List[str]			):
           requires_backends(cls     ,							['flax']			)






class        lowercase_      (						metaclass=lowerCAmelCase_							):
     A_											=			["flax"]





     def __init__(     self     :					int     ,							*__lowerCamelCase     :					str     ,							**__lowerCamelCase     :					Union[str, Any]			):
           requires_backends(self     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Optional[Any]     ,							*__lowerCamelCase     :					List[str]     ,							**__lowerCamelCase     :					Optional[int]			):
           requires_backends(cls     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Optional[Any]     ,							*__lowerCamelCase     :					Optional[Any]     ,							**__lowerCamelCase     :					Optional[int]			):
           requires_backends(cls     ,							['flax']			)






class        lowercase_      (						metaclass=lowerCAmelCase_							):
     A_											=			["flax"]





     def __init__(     self     :					List[str]     ,							*__lowerCamelCase     :					str     ,							**__lowerCamelCase     :					str			):
           requires_backends(self     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Union[str, Any]     ,							*__lowerCamelCase     :					str     ,							**__lowerCamelCase     :					str			):
           requires_backends(cls     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Any     ,							*__lowerCamelCase     :					Tuple     ,							**__lowerCamelCase     :					Optional[int]			):
           requires_backends(cls     ,							['flax']			)






class        lowercase_      (						metaclass=lowerCAmelCase_							):
     A_											=			["flax"]





     def __init__(     self     :					Optional[Any]     ,							*__lowerCamelCase     :					Optional[Any]     ,							**__lowerCamelCase     :					str			):
           requires_backends(self     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					str     ,							*__lowerCamelCase     :					Dict     ,							**__lowerCamelCase     :					int			):
           requires_backends(cls     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Optional[Any]     ,							*__lowerCamelCase     :					Union[str, Any]     ,							**__lowerCamelCase     :					Union[str, Any]			):
           requires_backends(cls     ,							['flax']			)






class        lowercase_      (						metaclass=lowerCAmelCase_							):
     A_											=			["flax"]





     def __init__(     self     :					Optional[int]     ,							*__lowerCamelCase     :					Tuple     ,							**__lowerCamelCase     :					Optional[Any]			):
           requires_backends(self     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					List[Any]     ,							*__lowerCamelCase     :					Dict     ,							**__lowerCamelCase     :					int			):
           requires_backends(cls     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Tuple     ,							*__lowerCamelCase     :					List[str]     ,							**__lowerCamelCase     :					str			):
           requires_backends(cls     ,							['flax']			)






class        lowercase_      (						metaclass=lowerCAmelCase_							):
     A_											=			["flax"]





     def __init__(     self     :					List[Any]     ,							*__lowerCamelCase     :					Dict     ,							**__lowerCamelCase     :					Union[str, Any]			):
           requires_backends(self     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Any     ,							*__lowerCamelCase     :					Union[str, Any]     ,							**__lowerCamelCase     :					Optional[int]			):
           requires_backends(cls     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					List[Any]     ,							*__lowerCamelCase     :					Optional[Any]     ,							**__lowerCamelCase     :					Optional[int]			):
           requires_backends(cls     ,							['flax']			)






class        lowercase_      (						metaclass=lowerCAmelCase_							):
     A_											=			["flax"]





     def __init__(     self     :					Dict     ,							*__lowerCamelCase     :					Union[str, Any]     ,							**__lowerCamelCase     :					Any			):
           requires_backends(self     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					List[Any]     ,							*__lowerCamelCase     :					Optional[int]     ,							**__lowerCamelCase     :					List[str]			):
           requires_backends(cls     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Union[str, Any]     ,							*__lowerCamelCase     :					str     ,							**__lowerCamelCase     :					Any			):
           requires_backends(cls     ,							['flax']			)






class        lowercase_      (						metaclass=lowerCAmelCase_							):
     A_											=			["flax"]





     def __init__(     self     :					Tuple     ,							*__lowerCamelCase     :					Union[str, Any]     ,							**__lowerCamelCase     :					Dict			):
           requires_backends(self     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					List[Any]     ,							*__lowerCamelCase     :					Tuple     ,							**__lowerCamelCase     :					List[Any]			):
           requires_backends(cls     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					int     ,							*__lowerCamelCase     :					Union[str, Any]     ,							**__lowerCamelCase     :					str			):
           requires_backends(cls     ,							['flax']			)






class        lowercase_      (						metaclass=lowerCAmelCase_							):
     A_											=			["flax"]





     def __init__(     self     :					Union[str, Any]     ,							*__lowerCamelCase     :					Optional[Any]     ,							**__lowerCamelCase     :					int			):
           requires_backends(self     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Any     ,							*__lowerCamelCase     :					List[str]     ,							**__lowerCamelCase     :					int			):
           requires_backends(cls     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					List[str]     ,							*__lowerCamelCase     :					Optional[Any]     ,							**__lowerCamelCase     :					List[str]			):
           requires_backends(cls     ,							['flax']			)






class        lowercase_      (						metaclass=lowerCAmelCase_							):
     A_											=			["flax"]





     def __init__(     self     :					Union[str, Any]     ,							*__lowerCamelCase     :					Optional[Any]     ,							**__lowerCamelCase     :					List[Any]			):
           requires_backends(self     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Any     ,							*__lowerCamelCase     :					Optional[int]     ,							**__lowerCamelCase     :					int			):
           requires_backends(cls     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					str     ,							*__lowerCamelCase     :					Tuple     ,							**__lowerCamelCase     :					List[Any]			):
           requires_backends(cls     ,							['flax']			)






class        lowercase_      (						metaclass=lowerCAmelCase_							):
     A_											=			["flax"]





     def __init__(     self     :					Optional[Any]     ,							*__lowerCamelCase     :					Union[str, Any]     ,							**__lowerCamelCase     :					Union[str, Any]			):
           requires_backends(self     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Union[str, Any]     ,							*__lowerCamelCase     :					Tuple     ,							**__lowerCamelCase     :					Optional[Any]			):
           requires_backends(cls     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					str     ,							*__lowerCamelCase     :					Dict     ,							**__lowerCamelCase     :					Optional[int]			):
           requires_backends(cls     ,							['flax']			)






class        lowercase_      (						metaclass=lowerCAmelCase_							):
     A_											=			["flax"]





     def __init__(     self     :					Union[str, Any]     ,							*__lowerCamelCase     :					List[Any]     ,							**__lowerCamelCase     :					Optional[int]			):
           requires_backends(self     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Optional[int]     ,							*__lowerCamelCase     :					Tuple     ,							**__lowerCamelCase     :					Tuple			):
           requires_backends(cls     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Dict     ,							*__lowerCamelCase     :					Dict     ,							**__lowerCamelCase     :					Optional[Any]			):
           requires_backends(cls     ,							['flax']			)






class        lowercase_      (						metaclass=lowerCAmelCase_							):
     A_											=			["flax"]





     def __init__(     self     :					str     ,							*__lowerCamelCase     :					int     ,							**__lowerCamelCase     :					Dict			):
           requires_backends(self     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					List[str]     ,							*__lowerCamelCase     :					Optional[int]     ,							**__lowerCamelCase     :					Tuple			):
           requires_backends(cls     ,							['flax']			)





     @classmethod
     def 			_lowerCAmelCase      (     cls     :					Dict     ,							*__lowerCamelCase     :					Optional[int]     ,							**__lowerCamelCase     :					Optional[Any]			):
           requires_backends(cls     ,							['flax']			)
