




'''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


A     =logging.get_logger(__name__)

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


class 			_a  (	__a ):
       __a				:     List[str]   				=					"""align_text_model"""
       def __init__(	self						:	Dict   ,				lowercase						:	str=30_522   ,				lowercase						:	List[Any]=768   ,				lowercase						:	Union[str, Any]=12   ,				lowercase						:	Optional[Any]=12   ,				lowercase						:	Union[str, Any]=3_072   ,				lowercase						:	Tuple="gelu"   ,				lowercase						:	Dict=0.1   ,				lowercase						:	int=0.1   ,				lowercase						:	Optional[int]=512   ,				lowercase						:	Union[str, Any]=2   ,				lowercase						:	Dict=0.02   ,				lowercase						:	Tuple=1E-12   ,				lowercase						:	Any=0   ,				lowercase						:	Any="absolute"   ,				lowercase						:	str=True   ,				**lowercase						:	Any   ,				):



           '''simple docstring'''

           super().__init__(**lowercase				)

           UpperCAmelCase			       =		vocab_size
           UpperCAmelCase			       =		hidden_size
           UpperCAmelCase			       =		num_hidden_layers
           UpperCAmelCase			       =		num_attention_heads
           UpperCAmelCase			       =		hidden_act
           UpperCAmelCase			       =		intermediate_size
           UpperCAmelCase			       =		hidden_dropout_prob
           UpperCAmelCase			       =		attention_probs_dropout_prob
           UpperCAmelCase			       =		max_position_embeddings
           UpperCAmelCase			       =		type_vocab_size
           UpperCAmelCase			       =		initializer_range
           UpperCAmelCase			       =		layer_norm_eps
           UpperCAmelCase			       =		position_embedding_type
           UpperCAmelCase			       =		use_cache
           UpperCAmelCase			       =		pad_token_id







       @classmethod
       def     A      (	cls						:	Any   ,				lowercase						:	Union[str, os.PathLike]   ,				**lowercase						:	Dict				):



           '''simple docstring'''

           cls._set_token_in_kwargs(lowercase				)

           UpperCAmelCase       ,     UpperCAmelCase			       =		cls.get_config_dict(lowercase   ,				**lowercase				)

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






class 			_a  (	__a ):
       __a				:     Dict   				=					"""align_vision_model"""
       def __init__(	self						:	int   ,				lowercase						:	int = 3   ,				lowercase						:	int = 600   ,				lowercase						:	float = 2.0   ,				lowercase						:	float = 3.1   ,				lowercase						:	int = 8   ,				lowercase						:	List[int] = [3, 3, 5, 3, 5, 5, 3]   ,				lowercase						:	List[int] = [32, 16, 24, 40, 80, 112, 192]   ,				lowercase						:	List[int] = [16, 24, 40, 80, 112, 192, 320]   ,				lowercase						:	List[int] = []   ,				lowercase						:	List[int] = [1, 2, 2, 2, 1, 2, 1]   ,				lowercase						:	List[int] = [1, 2, 2, 3, 3, 4, 1]   ,				lowercase						:	List[int] = [1, 6, 6, 6, 6, 6, 6]   ,				lowercase						:	float = 0.25   ,				lowercase						:	str = "swish"   ,				lowercase						:	int = 2_560   ,				lowercase						:	str = "mean"   ,				lowercase						:	float = 0.02   ,				lowercase						:	float = 0.001   ,				lowercase						:	float = 0.99   ,				lowercase						:	float = 0.2   ,				**lowercase						:	Optional[Any]   ,				):



           '''simple docstring'''

           super().__init__(**lowercase				)

           UpperCAmelCase			       =		num_channels
           UpperCAmelCase			       =		image_size
           UpperCAmelCase			       =		width_coefficient
           UpperCAmelCase			       =		depth_coefficient
           UpperCAmelCase			       =		depth_divisor
           UpperCAmelCase			       =		kernel_sizes
           UpperCAmelCase			       =		in_channels
           UpperCAmelCase			       =		out_channels
           UpperCAmelCase			       =		depthwise_padding
           UpperCAmelCase			       =		strides
           UpperCAmelCase			       =		num_block_repeats
           UpperCAmelCase			       =		expand_ratios
           UpperCAmelCase			       =		squeeze_expansion_ratio
           UpperCAmelCase			       =		hidden_act
           UpperCAmelCase			       =		hidden_dim
           UpperCAmelCase			       =		pooling_type
           UpperCAmelCase			       =		initializer_range
           UpperCAmelCase			       =		batch_norm_eps
           UpperCAmelCase			       =		batch_norm_momentum
           UpperCAmelCase			       =		drop_connect_rate
           UpperCAmelCase			       =		sum(lowercase				) * 4







       @classmethod
       def     A      (	cls						:	Optional[Any]   ,				lowercase						:	Union[str, os.PathLike]   ,				**lowercase						:	Tuple				):



           '''simple docstring'''

           cls._set_token_in_kwargs(lowercase				)

           UpperCAmelCase       ,     UpperCAmelCase			       =		cls.get_config_dict(lowercase   ,				**lowercase				)

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






class 			_a  (	__a ):
       __a				:     List[Any]   				=					"""align"""
       __a				:     str   				=					True
       def __init__(	self						:	Optional[int]   ,				lowercase						:	Optional[Any]=None   ,				lowercase						:	Optional[int]=None   ,				lowercase						:	List[Any]=640   ,				lowercase						:	Optional[int]=1.0   ,				lowercase						:	List[Any]=0.02   ,				**lowercase						:	List[str]   ,				):



           '''simple docstring'''

           super().__init__(**lowercase				)

           if text_config is None:
               UpperCAmelCase			       =		{}
               logger.info('''text_config is None. Initializing the AlignTextConfig with default values.'''				)

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

           UpperCAmelCase			       =		AlignTextConfig(**lowercase				)
           UpperCAmelCase			       =		AlignVisionConfig(**lowercase				)

           UpperCAmelCase			       =		projection_dim
           UpperCAmelCase			       =		temperature_init_value
           UpperCAmelCase			       =		initializer_range
       @classmethod
       def     A      (	cls						:	str   ,				lowercase						:	AlignTextConfig   ,				lowercase						:	AlignVisionConfig   ,				**lowercase						:	List[Any]				):



           '''simple docstring'''

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







       def     A      (	self						:	int				):



           '''simple docstring'''

           UpperCAmelCase			       =		copy.deepcopy(self.__dict__				)
           UpperCAmelCase			       =		self.text_config.to_dict()
           UpperCAmelCase			       =		self.vision_config.to_dict()
           UpperCAmelCase			       =		self.__class__.model_type
           return output










'''simple docstring'''







import math
from typing import Optional

import numpy as np

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


A     =logging.get_logger(__name__)

A     ={
    '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  (	__a ):
       __a				:     Union[str, Any]   				=					"""encodec"""
       def __init__(	self						:	Tuple   ,				lowercase						:	List[str]=[1.5, 3.0, 6.0, 12.0, 24.0]   ,				lowercase						:	Any=24_000   ,				lowercase						:	str=1   ,				lowercase						:	Optional[int]=False   ,				lowercase						:	Optional[Any]=None   ,				lowercase						:	str=None   ,				lowercase						:	Tuple=128   ,				lowercase						:	Union[str, Any]=32   ,				lowercase						:	Union[str, Any]=1   ,				lowercase						:	Optional[Any]=[8, 5, 4, 2]   ,				lowercase						:	Any="weight_norm"   ,				lowercase						:	Tuple=7   ,				lowercase						:	int=7   ,				lowercase						:	Dict=3   ,				lowercase						:	List[Any]=2   ,				lowercase						:	str=True   ,				lowercase						:	List[str]="reflect"   ,				lowercase						:	List[Any]=2   ,				lowercase						:	Optional[Any]=2   ,				lowercase						:	int=1.0   ,				lowercase						:	Dict=1_024   ,				lowercase						:	str=None   ,				lowercase						:	Union[str, Any]=True   ,				**lowercase						:	Optional[int]   ,				):



           '''simple docstring'''

           UpperCAmelCase			       =		target_bandwidths
           UpperCAmelCase			       =		sampling_rate
           UpperCAmelCase			       =		audio_channels
           UpperCAmelCase			       =		normalize
           UpperCAmelCase			       =		chunk_length_s
           UpperCAmelCase			       =		overlap
           UpperCAmelCase			       =		hidden_size
           UpperCAmelCase			       =		num_filters
           UpperCAmelCase			       =		num_residual_layers
           UpperCAmelCase			       =		upsampling_ratios
           UpperCAmelCase			       =		norm_type
           UpperCAmelCase			       =		kernel_size
           UpperCAmelCase			       =		last_kernel_size
           UpperCAmelCase			       =		residual_kernel_size
           UpperCAmelCase			       =		dilation_growth_rate
           UpperCAmelCase			       =		use_causal_conv
           UpperCAmelCase			       =		pad_mode
           UpperCAmelCase			       =		compress
           UpperCAmelCase			       =		num_lstm_layers
           UpperCAmelCase			       =		trim_right_ratio
           UpperCAmelCase			       =		codebook_size
           UpperCAmelCase			       =		codebook_dim if codebook_dim is not None else hidden_size
           UpperCAmelCase			       =		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__(**lowercase				)
       @property
       def     A      (	self						:	Dict				):



           '''simple docstring'''

           if self.chunk_length_s is None:
               return None
           else:
               return int(self.chunk_length_s * self.sampling_rate				)
       @property
       def     A      (	self						:	Union[str, Any]				):



           '''simple docstring'''

           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     A      (	self						:	Any				):



           '''simple docstring'''

           UpperCAmelCase			       =		np.prod(self.upsampling_ratios				)
           return math.ceil(self.sampling_rate / hop_length				)







       @property
       def     A      (	self						:	Optional[int]				):



           '''simple docstring'''

           return int(1_000 * self.target_bandwidths[-1] // (self.frame_rate * 10)				)




