


"""simple docstring"""


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


if TYPE_CHECKING:
   pass

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


__snake_case    					=					logging.get_logger(__name__)

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

class 				_SCREAMING_SNAKE_CASE				(							__UpperCAmelCase  ):
   """simple docstring"""



   _a   :       Tuple									=    '''align_text_model'''


   def __init__(						self ,     lowerCamelCase__=3_0522 ,     lowerCamelCase__=768 ,     lowerCamelCase__=12 ,     lowerCamelCase__=12 ,     lowerCamelCase__=3072 ,     lowerCamelCase__="gelu" ,     lowerCamelCase__=0.1 ,     lowerCamelCase__=0.1 ,     lowerCamelCase__=512 ,     lowerCamelCase__=2 ,     lowerCamelCase__=0.02 ,     lowerCamelCase__=1E-12 ,     lowerCamelCase__=0 ,     lowerCamelCase__="absolute" ,     lowerCamelCase__=True ,     **lowerCamelCase__ ,     )      ->							List[Any]:
    super().__init__(**lowerCamelCase__						)

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







   @classmethod
   def 					UpperCAmelCase__(						cls ,     lowerCamelCase__ ,     **lowerCamelCase__						)      ->							"PretrainedConfig":
    cls._set_token_in_kwargs(lowerCamelCase__						)

    lowercase__	,       lowercase__       :       List[Any]				=						cls.get_config_dict(lowerCamelCase__ ,     **lowerCamelCase__						)

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

class 				_SCREAMING_SNAKE_CASE				(							__UpperCAmelCase  ):
   """simple docstring"""



   _a   :       int									=    '''align_vision_model'''


   def __init__(						self ,     lowerCamelCase__ = 3 ,     lowerCamelCase__ = 600 ,     lowerCamelCase__ = 2.0 ,     lowerCamelCase__ = 3.1 ,     lowerCamelCase__ = 8 ,     lowerCamelCase__ = [3, 3, 5, 3, 5, 5, 3] ,     lowerCamelCase__ = [32, 16, 24, 40, 80, 112, 192] ,     lowerCamelCase__ = [16, 24, 40, 80, 112, 192, 320] ,     lowerCamelCase__ = [] ,     lowerCamelCase__ = [1, 2, 2, 2, 1, 2, 1] ,     lowerCamelCase__ = [1, 2, 2, 3, 3, 4, 1] ,     lowerCamelCase__ = [1, 6, 6, 6, 6, 6, 6] ,     lowerCamelCase__ = 0.25 ,     lowerCamelCase__ = "swish" ,     lowerCamelCase__ = 2560 ,     lowerCamelCase__ = "mean" ,     lowerCamelCase__ = 0.02 ,     lowerCamelCase__ = 0.001 ,     lowerCamelCase__ = 0.99 ,     lowerCamelCase__ = 0.2 ,     **lowerCamelCase__ ,     )      ->							int:
    super().__init__(**lowerCamelCase__						)

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







   @classmethod
   def 					UpperCAmelCase__(						cls ,     lowerCamelCase__ ,     **lowerCamelCase__						)      ->							"PretrainedConfig":
    cls._set_token_in_kwargs(lowerCamelCase__						)

    lowercase__	,       lowercase__       :       Tuple				=						cls.get_config_dict(lowerCamelCase__ ,     **lowerCamelCase__						)

    # get the vision config dict if we are loading from AlignConfig
    if config_dict.get("""model_type"""						) == "align":
     lowercase__       :       Dict				=						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 				_SCREAMING_SNAKE_CASE				(							__UpperCAmelCase  ):
   """simple docstring"""



   _a   :       Tuple									=    '''align'''
   _a   :       Any									=    True


   def __init__(						self ,     lowerCamelCase__=None ,     lowerCamelCase__=None ,     lowerCamelCase__=640 ,     lowerCamelCase__=1.0 ,     lowerCamelCase__=0.02 ,     **lowerCamelCase__ ,     )      ->							Tuple:
    super().__init__(**lowerCamelCase__						)

    if text_config is None:
     lowercase__       :       Optional[int]				=						{}
     logger.info("""text_config is None. Initializing the AlignTextConfig with default values."""						)

    if vision_config is None:
     lowercase__       :       Any				=						{}
     logger.info("""vision_config is None. Initializing the AlignVisionConfig with default values."""						)

    lowercase__       :       List[str]				=						AlignTextConfig(**lowerCamelCase__						)
    lowercase__       :       Tuple				=						AlignVisionConfig(**lowerCamelCase__						)

    lowercase__       :       str				=						projection_dim
    lowercase__       :       Optional[int]				=						temperature_init_value
    lowercase__       :       str				=						initializer_range


   @classmethod
   def 					UpperCAmelCase__(						cls ,     lowerCamelCase__ ,     lowerCamelCase__ ,     **lowerCamelCase__						)      ->							List[str]:
    return cls(text_config=text_config.to_dict() ,     vision_config=vision_config.to_dict() ,     **lowerCamelCase__						)







   def 					UpperCAmelCase__(						self						)      ->							List[Any]:
    lowercase__       :       int				=						copy.deepcopy(self.__dict__						)
    lowercase__       :       Optional[int]				=						self.text_config.to_dict()
    lowercase__       :       Optional[int]				=						self.vision_config.to_dict()
    lowercase__       :       str				=						self.__class__.model_type
    return output



"""simple docstring"""


from math import cos, sin, sqrt, tau

from audio_filters.iir_filter import IIRFilter


def    _lowerCamelCase   (     lowerCamelCase__	:							int       ,		lowerCamelCase__	:							int       ,		lowerCamelCase__	:							float = 1 / sqrt(2  )  ):
 lowercase__       :       str				=						tau * frequency / samplerate
 lowercase__       :       Union[str, Any]				=						sin(lowerCamelCase__  )
 lowercase__       :       int				=						cos(lowerCamelCase__  )
 lowercase__       :       Union[str, Any]				=						_sin / (2 * q_factor)

 lowercase__       :       str				=						(1 - _cos) / 2
 lowercase__       :       Optional[Any]				=						1 - _cos

 lowercase__       :       List[Any]				=						1 + alpha
 lowercase__       :       Dict				=						-2 * _cos
 lowercase__       :       List[str]				=						1 - alpha

 lowercase__       :       int				=						IIRFilter(2  )
 filt.set_coefficients([aa, aa, aa]       ,		[ba, ba, ba]  )
 return filt


def    _lowerCamelCase   (     lowerCamelCase__	:							int       ,		lowerCamelCase__	:							int       ,		lowerCamelCase__	:							float = 1 / sqrt(2  )  ):
 lowercase__       :       Optional[int]				=						tau * frequency / samplerate
 lowercase__       :       Any				=						sin(lowerCamelCase__  )
 lowercase__       :       Any				=						cos(lowerCamelCase__  )
 lowercase__       :       Tuple				=						_sin / (2 * q_factor)

 lowercase__       :       Tuple				=						(1 + _cos) / 2
 lowercase__       :       str				=						-1 - _cos

 lowercase__       :       Dict				=						1 + alpha
 lowercase__       :       Dict				=						-2 * _cos
 lowercase__       :       int				=						1 - alpha

 lowercase__       :       str				=						IIRFilter(2  )
 filt.set_coefficients([aa, aa, aa]       ,		[ba, ba, ba]  )
 return filt


def    _lowerCamelCase   (     lowerCamelCase__	:							int       ,		lowerCamelCase__	:							int       ,		lowerCamelCase__	:							float = 1 / sqrt(2  )  ):
 lowercase__       :       Optional[int]				=						tau * frequency / samplerate
 lowercase__       :       str				=						sin(lowerCamelCase__  )
 lowercase__       :       int				=						cos(lowerCamelCase__  )
 lowercase__       :       Dict				=						_sin / (2 * q_factor)

 lowercase__       :       Dict				=						_sin / 2
 lowercase__       :       Union[str, Any]				=						0
 lowercase__       :       int				=						-ba

 lowercase__       :       List[Any]				=						1 + alpha
 lowercase__       :       Tuple				=						-2 * _cos
 lowercase__       :       List[str]				=						1 - alpha

 lowercase__       :       Dict				=						IIRFilter(2  )
 filt.set_coefficients([aa, aa, aa]       ,		[ba, ba, ba]  )
 return filt


def    _lowerCamelCase   (     lowerCamelCase__	:							int       ,		lowerCamelCase__	:							int       ,		lowerCamelCase__	:							float = 1 / sqrt(2  )  ):
 lowercase__       :       str				=						tau * frequency / samplerate
 lowercase__       :       Dict				=						sin(lowerCamelCase__  )
 lowercase__       :       Union[str, Any]				=						cos(lowerCamelCase__  )
 lowercase__       :       Tuple				=						_sin / (2 * q_factor)

 lowercase__       :       List[Any]				=						1 - alpha
 lowercase__       :       Any				=						-2 * _cos
 lowercase__       :       Optional[Any]				=						1 + alpha

 lowercase__       :       List[Any]				=						IIRFilter(2  )
 filt.set_coefficients([ba, ba, ba]       ,		[ba, ba, ba]  )
 return filt


def    _lowerCamelCase   (     lowerCamelCase__	:							int       ,		lowerCamelCase__	:							int       ,		lowerCamelCase__	:							float       ,		lowerCamelCase__	:							float = 1 / sqrt(2  )       ,		):
 lowercase__       :       Tuple				=						tau * frequency / samplerate
 lowercase__       :       str				=						sin(lowerCamelCase__  )
 lowercase__       :       List[str]				=						cos(lowerCamelCase__  )
 lowercase__       :       Optional[int]				=						_sin / (2 * q_factor)
 lowercase__       :       Optional[Any]				=						10 ** (gain_db / 40)

 lowercase__       :       Optional[Any]				=						1 + alpha * big_a
 lowercase__       :       Dict				=						-2 * _cos
 lowercase__       :       Tuple				=						1 - alpha * big_a
 lowercase__       :       List[str]				=						1 + alpha / big_a
 lowercase__       :       List[Any]				=						-2 * _cos
 lowercase__       :       Optional[int]				=						1 - alpha / big_a

 lowercase__       :       Union[str, Any]				=						IIRFilter(2  )
 filt.set_coefficients([aa, aa, aa]       ,		[ba, ba, ba]  )
 return filt


def    _lowerCamelCase   (     lowerCamelCase__	:							int       ,		lowerCamelCase__	:							int       ,		lowerCamelCase__	:							float       ,		lowerCamelCase__	:							float = 1 / sqrt(2  )       ,		):
 lowercase__       :       Optional[int]				=						tau * frequency / samplerate
 lowercase__       :       Dict				=						sin(lowerCamelCase__  )
 lowercase__       :       Union[str, Any]				=						cos(lowerCamelCase__  )
 lowercase__       :       int				=						_sin / (2 * q_factor)
 lowercase__       :       Union[str, Any]				=						10 ** (gain_db / 40)
 lowercase__       :       Dict				=						(big_a + 1) - (big_a - 1) * _cos
 lowercase__       :       Union[str, Any]				=						(big_a + 1) + (big_a - 1) * _cos
 lowercase__       :       List[Any]				=						(big_a - 1) - (big_a + 1) * _cos
 lowercase__       :       Dict				=						(big_a - 1) + (big_a + 1) * _cos
 lowercase__       :       Optional[int]				=						2 * sqrt(lowerCamelCase__  ) * alpha

 lowercase__       :       str				=						big_a * (pmc + aaa)
 lowercase__       :       Optional[Any]				=						2 * big_a * mpc
 lowercase__       :       str				=						big_a * (pmc - aaa)
 lowercase__       :       Dict				=						ppmc + aaa
 lowercase__       :       List[Any]				=						-2 * pmpc
 lowercase__       :       List[Any]				=						ppmc - aaa

 lowercase__       :       Optional[int]				=						IIRFilter(2  )
 filt.set_coefficients([aa, aa, aa]       ,		[ba, ba, ba]  )
 return filt






def    _lowerCamelCase   (     lowerCamelCase__	:							int       ,		lowerCamelCase__	:							int       ,		lowerCamelCase__	:							float       ,		lowerCamelCase__	:							float = 1 / sqrt(2  )       ,		):
 lowercase__       :       int				=						tau * frequency / samplerate
 lowercase__       :       List[Any]				=						sin(lowerCamelCase__  )
 lowercase__       :       List[Any]				=						cos(lowerCamelCase__  )
 lowercase__       :       List[str]				=						_sin / (2 * q_factor)
 lowercase__       :       int				=						10 ** (gain_db / 40)
 lowercase__       :       str				=						(big_a + 1) - (big_a - 1) * _cos
 lowercase__       :       Optional[Any]				=						(big_a + 1) + (big_a - 1) * _cos
 lowercase__       :       Optional[int]				=						(big_a - 1) - (big_a + 1) * _cos
 lowercase__       :       int				=						(big_a - 1) + (big_a + 1) * _cos
 lowercase__       :       Optional[Any]				=						2 * sqrt(lowerCamelCase__  ) * alpha

 lowercase__       :       str				=						big_a * (ppmc + aaa)
 lowercase__       :       Union[str, Any]				=						-2 * big_a * pmpc
 lowercase__       :       List[Any]				=						big_a * (ppmc - aaa)
 lowercase__       :       str				=						pmc + aaa
 lowercase__       :       int				=						2 * mpc
 lowercase__       :       Any				=						pmc - aaa

 lowercase__       :       int				=						IIRFilter(2  )
 filt.set_coefficients([aa, aa, aa]       ,		[ba, ba, ba]  )
 return filt