


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					:		Tuple      =    logging.get_logger(__name__)

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

class     a		(_lowerCAmelCase				):




							"""simple docstring"""


							__UpperCAmelCase   :							List[str]					  =  "align_text_model"

							def __init__(							self	:  str   ,     lowerCamelCase	:  str=30522   ,     lowerCamelCase	:  Optional[int]=768   ,     lowerCamelCase	:  Union[str, Any]=12   ,     lowerCamelCase	:  Any=12   ,     lowerCamelCase	:  Dict=3072   ,     lowerCamelCase	:  Optional[Any]="gelu"   ,     lowerCamelCase	:  Dict=0.1   ,     lowerCamelCase	:  List[str]=0.1   ,     lowerCamelCase	:  List[Any]=512   ,     lowerCamelCase	:  List[str]=2   ,     lowerCamelCase	:  Optional[int]=0.02   ,     lowerCamelCase	:  Optional[int]=1E-12   ,     lowerCamelCase	:  Tuple=0   ,     lowerCamelCase	:  List[str]="absolute"   ,     lowerCamelCase	:  Tuple=True   ,     **lowerCamelCase	:  Tuple   ,     )     ->   Tuple:
														super().__init__(**_SCREAMING_SNAKE_CASE    )

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






							@classmethod
							def    __snake_case (							cls	:  Optional[int]   ,     lowerCamelCase	:  Any   ,     **lowerCamelCase	:  List[Any]    )     ->   "PretrainedConfig":
														cls._set_token_in_kwargs(_SCREAMING_SNAKE_CASE    )

														__snake_case		:      int										=       cls.get_config_dict(_SCREAMING_SNAKE_CASE   ,     **_SCREAMING_SNAKE_CASE    )

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

class     a		(_lowerCAmelCase				):




							"""simple docstring"""


							__UpperCAmelCase   :							List[Any]					  =  "align_vision_model"

							def __init__(							self	:  int   ,     lowerCamelCase	:  Optional[int] = 3   ,     lowerCamelCase	:  Optional[int] = 600   ,     lowerCamelCase	:  Optional[Any] = 2.0   ,     lowerCamelCase	:  Optional[int] = 3.1   ,     lowerCamelCase	:  Union[str, Any] = 8   ,     lowerCamelCase	:  Dict = [3, 3, 5, 3, 5, 5, 3]   ,     lowerCamelCase	:  Optional[Any] = [32, 16, 24, 40, 80, 112, 192]   ,     lowerCamelCase	:  Optional[Any] = [16, 24, 40, 80, 112, 192, 320]   ,     lowerCamelCase	:  Dict = []   ,     lowerCamelCase	:  str = [1, 2, 2, 2, 1, 2, 1]   ,     lowerCamelCase	:  int = [1, 2, 2, 3, 3, 4, 1]   ,     lowerCamelCase	:  Any = [1, 6, 6, 6, 6, 6, 6]   ,     lowerCamelCase	:  int = 0.25   ,     lowerCamelCase	:  Optional[Any] = "swish"   ,     lowerCamelCase	:  List[Any] = 2560   ,     lowerCamelCase	:  List[Any] = "mean"   ,     lowerCamelCase	:  Dict = 0.02   ,     lowerCamelCase	:  str = 0.0_01   ,     lowerCamelCase	:  List[str] = 0.99   ,     lowerCamelCase	:  Optional[int] = 0.2   ,     **lowerCamelCase	:  int   ,     )     ->   Optional[int]:
														super().__init__(**_SCREAMING_SNAKE_CASE    )

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






							@classmethod
							def    __snake_case (							cls	:  List[Any]   ,     lowerCamelCase	:  str   ,     **lowerCamelCase	:  Optional[int]    )     ->   "PretrainedConfig":
														cls._set_token_in_kwargs(_SCREAMING_SNAKE_CASE    )

														__snake_case		:      Any										=       cls.get_config_dict(_SCREAMING_SNAKE_CASE   ,     **_SCREAMING_SNAKE_CASE    )

														# get the vision config dict if we are loading from AlignConfig
														if config_dict.get("model_type"    ) == "align":
																					__snake_case		:      Optional[Any]										=       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(_SCREAMING_SNAKE_CASE   ,     **_SCREAMING_SNAKE_CASE    )

class     a		(_lowerCAmelCase				):




							"""simple docstring"""


							__UpperCAmelCase   :							List[Any]					  =  "align"
							__UpperCAmelCase   :							List[str]					  =  True

							def __init__(							self	:  Optional[Any]   ,     lowerCamelCase	:  List[str]=None   ,     lowerCamelCase	:  Tuple=None   ,     lowerCamelCase	:  List[str]=640   ,     lowerCamelCase	:  Tuple=1.0   ,     lowerCamelCase	:  Any=0.02   ,     **lowerCamelCase	:  List[str]   ,     )     ->   int:
														super().__init__(**_SCREAMING_SNAKE_CASE    )

														if text_config is None:
																					__snake_case		:      Dict										=       {}
																					logger.info("text_config is None. Initializing the AlignTextConfig with default values."    )

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

														__snake_case		:      List[str]										=       AlignTextConfig(**_SCREAMING_SNAKE_CASE    )
														__snake_case		:      str										=       AlignVisionConfig(**_SCREAMING_SNAKE_CASE    )

														__snake_case		:      Union[str, Any]										=       projection_dim
														__snake_case		:      List[Any]										=       temperature_init_value
														__snake_case		:      int										=       initializer_range

							@classmethod
							def    __snake_case (							cls	:  Tuple   ,     lowerCamelCase	:  int   ,     lowerCamelCase	:  Union[str, Any]   ,     **lowerCamelCase	:  int    )     ->   int:
														return cls(text_config=text_config.to_dict()   ,     vision_config=vision_config.to_dict()   ,     **_SCREAMING_SNAKE_CASE    )






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





import math
from typing import Optional

import numpy as np

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


_snake_case					:		Union[str, Any]      =    logging.get_logger(__name__)

_snake_case					:		List[str]      =    {
    "facebook/encodec_24khz": "https://huggingface.co/facebook/encodec_24khz/resolve/main/config.json",
    "facebook/encodec_48khz": "https://huggingface.co/facebook/encodec_48khz/resolve/main/config.json",
}

class     a		(_lowerCAmelCase				):




							"""simple docstring"""


							__UpperCAmelCase   :							Tuple					  =  "encodec"

							def __init__(							self	:  Any   ,     lowerCamelCase	:  Optional[int]=[1.5, 3.0, 6.0, 12.0, 24.0]   ,     lowerCamelCase	:  List[str]=24000   ,     lowerCamelCase	:  int=1   ,     lowerCamelCase	:  Optional[int]=False   ,     lowerCamelCase	:  Dict=None   ,     lowerCamelCase	:  Tuple=None   ,     lowerCamelCase	:  Optional[int]=128   ,     lowerCamelCase	:  Optional[int]=32   ,     lowerCamelCase	:  List[str]=1   ,     lowerCamelCase	:  str=[8, 5, 4, 2]   ,     lowerCamelCase	:  List[str]="weight_norm"   ,     lowerCamelCase	:  Any=7   ,     lowerCamelCase	:  Tuple=7   ,     lowerCamelCase	:  int=3   ,     lowerCamelCase	:  int=2   ,     lowerCamelCase	:  Union[str, Any]=True   ,     lowerCamelCase	:  List[Any]="reflect"   ,     lowerCamelCase	:  Union[str, Any]=2   ,     lowerCamelCase	:  Optional[int]=2   ,     lowerCamelCase	:  int=1.0   ,     lowerCamelCase	:  Optional[Any]=1024   ,     lowerCamelCase	:  Optional[Any]=None   ,     lowerCamelCase	:  str=True   ,     **lowerCamelCase	:  Dict   ,     )     ->   Any:
														__snake_case		:      Tuple										=       target_bandwidths
														__snake_case		:      Union[str, Any]										=       sampling_rate
														__snake_case		:      Union[str, Any]										=       audio_channels
														__snake_case		:      Dict										=       normalize
														__snake_case		:      List[Any]										=       chunk_length_s
														__snake_case		:      Tuple										=       overlap
														__snake_case		:      Optional[int]										=       hidden_size
														__snake_case		:      List[Any]										=       num_filters
														__snake_case		:      Union[str, Any]										=       num_residual_layers
														__snake_case		:      Optional[int]										=       upsampling_ratios
														__snake_case		:      List[str]										=       norm_type
														__snake_case		:      Optional[int]										=       kernel_size
														__snake_case		:      Dict										=       last_kernel_size
														__snake_case		:      Tuple										=       residual_kernel_size
														__snake_case		:      List[Any]										=       dilation_growth_rate
														__snake_case		:      Optional[int]										=       use_causal_conv
														__snake_case		:      Tuple										=       pad_mode
														__snake_case		:      Union[str, Any]										=       compress
														__snake_case		:      Union[str, Any]										=       num_lstm_layers
														__snake_case		:      int										=       trim_right_ratio
														__snake_case		:      Tuple										=       codebook_size
														__snake_case		:      Optional[Any]										=       codebook_dim if codebook_dim is not None else hidden_size
														__snake_case		:      int										=       use_conv_shortcut

														if self.norm_type not in ["weight_norm", "time_group_norm"]:
																					raise ValueError(
																					    F'self.norm_type must be one of `"weight_norm"`, `"time_group_norm"`), got {self.norm_type}'    )

														super().__init__(**lowerCamelCase    )

							@property
							def    __snake_case (							self	:  int    )     ->   Optional[int]:
														if self.chunk_length_s is None:
																					return None
														else:
																					return int(self.chunk_length_s * self.sampling_rate    )

							@property
							def    __snake_case (							self	:  Union[str, Any]    )     ->   Optional[int]:
														if self.chunk_length_s is None or self.overlap is None:
																					return None
														else:
																					return max(1   ,     int((1.0 - self.overlap) * self.chunk_length    )    )

							@property
							def    __snake_case (							self	:  Optional[Any]    )     ->   int:
														__snake_case		:      Union[str, Any]										=       np.prod(self.upsampling_ratios    )
														return math.ceil(self.sampling_rate / hop_length    )






							@property
							def    __snake_case (							self	:  Optional[Any]    )     ->   int:
														return int(1000 * self.target_bandwidths[-1] // (self.frame_rate * 10)    )

