


"""simple docstring"""
import math
from typing import Optional

import numpy as np

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


__SCREAMING_SNAKE_CASE							:    Dict		=    logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE							:    Union[str, Any]		=    {
    '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     (snake_case__):





							'''simple docstring'''

							__lowercase:		str							      =    """encodec"""



							def __init__(				self							:      Optional[Any]		,       UpperCAmelCase_							:      int=[1.5, 3.0, 6.0, 12.0, 24.0]		,       UpperCAmelCase_							:      Dict=24_000		,       UpperCAmelCase_							:      List[str]=1		,       UpperCAmelCase_							:      Tuple=False		,       UpperCAmelCase_							:      Tuple=None		,       UpperCAmelCase_							:      Optional[Any]=None		,       UpperCAmelCase_							:      Dict=128		,       UpperCAmelCase_							:      int=32		,       UpperCAmelCase_							:      Tuple=1		,       UpperCAmelCase_							:      Any=[8, 5, 4, 2]		,       UpperCAmelCase_							:      Union[str, Any]="weight_norm"		,       UpperCAmelCase_							:      Dict=7		,       UpperCAmelCase_							:      str=7		,       UpperCAmelCase_							:      int=3		,       UpperCAmelCase_							:      List[str]=2		,       UpperCAmelCase_							:      List[Any]=True		,       UpperCAmelCase_							:      Tuple="reflect"		,       UpperCAmelCase_							:      List[Any]=2		,       UpperCAmelCase_							:      Dict=2		,       UpperCAmelCase_							:      Union[str, Any]=1.0		,       UpperCAmelCase_							:      List[str]=1_024		,       UpperCAmelCase_							:      int=None		,       UpperCAmelCase_							:      str=True		,       **UpperCAmelCase_							:      str		,       )					->Optional[Any]:



														"""simple docstring"""



														snake_case_           =		target_bandwidths
														snake_case_           =		sampling_rate
														snake_case_           =		audio_channels
														snake_case_           =		normalize
														snake_case_           =		chunk_length_s
														snake_case_           =		overlap
														snake_case_           =		hidden_size
														snake_case_           =		num_filters
														snake_case_           =		num_residual_layers
														snake_case_           =		upsampling_ratios
														snake_case_           =		norm_type
														snake_case_           =		kernel_size
														snake_case_           =		last_kernel_size
														snake_case_           =		residual_kernel_size
														snake_case_           =		dilation_growth_rate
														snake_case_           =		use_causal_conv
														snake_case_           =		pad_mode
														snake_case_           =		compress
														snake_case_           =		num_lstm_layers
														snake_case_           =		trim_right_ratio
														snake_case_           =		codebook_size
														snake_case_           =		codebook_dim if codebook_dim is not None else hidden_size
														snake_case_           =		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__(**UpperCAmelCase_       )



							@property
							def 		lowerCAmelCase       (				self							:      List[Any]       )					->Optional[int]:



														"""simple docstring"""



														if self.chunk_length_s is None:
																					return None
														else:
																					return int(self.chunk_length_s * self.sampling_rate       )



							@property
							def 		lowerCAmelCase       (				self							:      str       )					->Optional[int]:



														"""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 		lowerCAmelCase       (				self							:      Any       )					->int:



														"""simple docstring"""



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



							@property
							def 		lowerCAmelCase       (				self							:      Optional[Any]       )					->int:



														"""simple docstring"""



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






"""simple docstring"""
from ....configuration_utils import PretrainedConfig
from ....utils import logging


__SCREAMING_SNAKE_CASE							:    str		=    logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE							:    str		=    {
    'speechbrain/m-ctc-t-large': 'https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json',
    # See all M-CTC-T models at https://huggingface.co/models?filter=mctct
}





class      __A     (snake_case__):





							'''simple docstring'''

							__lowercase:		Any							      =    """mctct"""



							def __init__(				self							:      Dict		,       UpperCAmelCase_							:      List[Any]=8_065		,       UpperCAmelCase_							:      Tuple=1_536		,       UpperCAmelCase_							:      Optional[Any]=36		,       UpperCAmelCase_							:      int=6_144		,       UpperCAmelCase_							:      Dict=4		,       UpperCAmelCase_							:      Any=384		,       UpperCAmelCase_							:      List[str]=920		,       UpperCAmelCase_							:      Any=1E-5		,       UpperCAmelCase_							:      Any=0.3		,       UpperCAmelCase_							:      Tuple="relu"		,       UpperCAmelCase_							:      Union[str, Any]=0.02		,       UpperCAmelCase_							:      Dict=0.3		,       UpperCAmelCase_							:      str=0.3		,       UpperCAmelCase_							:      Any=1		,       UpperCAmelCase_							:      Any=0		,       UpperCAmelCase_							:      int=2		,       UpperCAmelCase_							:      str=1		,       UpperCAmelCase_							:      Tuple=0.3		,       UpperCAmelCase_							:      Optional[Any]=1		,       UpperCAmelCase_							:      Optional[Any]=(7,)		,       UpperCAmelCase_							:      Optional[Any]=(3,)		,       UpperCAmelCase_							:      List[str]=80		,       UpperCAmelCase_							:      Tuple=1		,       UpperCAmelCase_							:      List[Any]=None		,       UpperCAmelCase_							:      List[str]="sum"		,       UpperCAmelCase_							:      Union[str, Any]=False		,       **UpperCAmelCase_							:      Any		,       )					->Dict:



														"""simple docstring"""



														super().__init__(**UpperCAmelCase_		,       pad_token_id=UpperCAmelCase_		,       bos_token_id=UpperCAmelCase_		,       eos_token_id=UpperCAmelCase_       )
														snake_case_           =		vocab_size
														snake_case_           =		hidden_size
														snake_case_           =		num_hidden_layers
														snake_case_           =		intermediate_size
														snake_case_           =		num_attention_heads
														snake_case_           =		attention_head_dim
														snake_case_           =		max_position_embeddings
														snake_case_           =		layer_norm_eps
														snake_case_           =		layerdrop
														snake_case_           =		hidden_act
														snake_case_           =		initializer_range
														snake_case_           =		hidden_dropout_prob
														snake_case_           =		attention_probs_dropout_prob
														snake_case_           =		pad_token_id
														snake_case_           =		bos_token_id
														snake_case_           =		eos_token_id
														snake_case_           =		conv_glu_dim
														snake_case_           =		conv_dropout
														snake_case_           =		num_conv_layers
														snake_case_           =		input_feat_per_channel
														snake_case_           =		input_channels
														snake_case_           =		conv_channels
														snake_case_           =		ctc_loss_reduction
														snake_case_           =		ctc_zero_infinity

														# prevents config testing fail with exporting to json
														snake_case_           =		list(UpperCAmelCase_       )
														snake_case_           =		list(UpperCAmelCase_       )

														if len(self.conv_kernel       ) != self.num_conv_layers:
																					raise ValueError(
																					    """Configuration for convolutional module is incorrect. """
																					    """It is required that `len(config.conv_kernel)` == `config.num_conv_layers` """
																					    F"""but is `len(config.conv_kernel) = {len(self.conv_kernel       )}`, """
																					    F"""`config.num_conv_layers = {self.num_conv_layers}`."""       )



