


"""simple docstring"""







import math
from typing import Optional

import numpy as np

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


a__    :							Optional[int]            =					logging.get_logger(__name__)

a__    :							Optional[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 			UpperCamelCase_     (			UpperCamelCase):

	"""simple docstring"""





	snake_case__    :  Optional[Any]    =      "encodec"




	def __init__(			self      :    Optional[int]      ,      UpperCAmelCase__      :    str=[1.5, 3.0, 6.0, 12.0, 24.0]      ,      UpperCAmelCase__      :    Tuple=2_4_0_0_0      ,      UpperCAmelCase__      :    List[str]=1      ,      UpperCAmelCase__      :    Dict=False      ,      UpperCAmelCase__      :    List[Any]=None      ,      UpperCAmelCase__      :    Tuple=None      ,      UpperCAmelCase__      :    List[str]=1_2_8      ,      UpperCAmelCase__      :    Any=3_2      ,      UpperCAmelCase__      :    Optional[int]=1      ,      UpperCAmelCase__      :    Optional[Any]=[8, 5, 4, 2]      ,      UpperCAmelCase__      :    Any="weight_norm"      ,      UpperCAmelCase__      :    List[str]=7      ,      UpperCAmelCase__      :    str=7      ,      UpperCAmelCase__      :    int=3      ,      UpperCAmelCase__      :    int=2      ,      UpperCAmelCase__      :    Any=True      ,      UpperCAmelCase__      :    Optional[int]="reflect"      ,      UpperCAmelCase__      :    Optional[Any]=2      ,      UpperCAmelCase__      :    Dict=2      ,      UpperCAmelCase__      :    Dict=1.0      ,      UpperCAmelCase__      :    Union[str, Any]=1_0_2_4      ,      UpperCAmelCase__      :    Dict=None      ,      UpperCAmelCase__      :    Any=True      ,      **UpperCAmelCase__      :    str      ,      )	->     Dict:
						__SCREAMING_SNAKE_CASE						       =    target_bandwidths
						__SCREAMING_SNAKE_CASE						       =    sampling_rate
						__SCREAMING_SNAKE_CASE						       =    audio_channels
						__SCREAMING_SNAKE_CASE						       =    normalize
						__SCREAMING_SNAKE_CASE						       =    chunk_length_s
						__SCREAMING_SNAKE_CASE						       =    overlap
						__SCREAMING_SNAKE_CASE						       =    hidden_size
						__SCREAMING_SNAKE_CASE						       =    num_filters
						__SCREAMING_SNAKE_CASE						       =    num_residual_layers
						__SCREAMING_SNAKE_CASE						       =    upsampling_ratios
						__SCREAMING_SNAKE_CASE						       =    norm_type
						__SCREAMING_SNAKE_CASE						       =    kernel_size
						__SCREAMING_SNAKE_CASE						       =    last_kernel_size
						__SCREAMING_SNAKE_CASE						       =    residual_kernel_size
						__SCREAMING_SNAKE_CASE						       =    dilation_growth_rate
						__SCREAMING_SNAKE_CASE						       =    use_causal_conv
						__SCREAMING_SNAKE_CASE						       =    pad_mode
						__SCREAMING_SNAKE_CASE						       =    compress
						__SCREAMING_SNAKE_CASE						       =    num_lstm_layers
						__SCREAMING_SNAKE_CASE						       =    trim_right_ratio
						__SCREAMING_SNAKE_CASE						       =    codebook_size
						__SCREAMING_SNAKE_CASE						       =    codebook_dim if codebook_dim is not None else hidden_size
						__SCREAMING_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   UpperCAmelCase_				(			self      :    Optional[int]       )	->     Optional[int]:
						if self.chunk_length_s is None:
											return None
						else:
											return int(self.chunk_length_s * self.sampling_rate       )




	@property
	def   UpperCAmelCase_				(			self      :    Tuple       )	->     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   UpperCAmelCase_				(			self      :    Any       )	->     int:
						__SCREAMING_SNAKE_CASE						       =    np.prod(self.upsampling_ratios       )
						return math.ceil(self.sampling_rate / hop_length       )




	@property
	def   UpperCAmelCase_				(			self      :    Optional[Any]       )	->     int:
						return int(1_0_0_0 * self.target_bandwidths[-1] // (self.frame_rate * 1_0)       )




"""simple docstring"""







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


a__    :							int            =					logging.get_logger(__name__)

a__    :							Tuple            =					{'''ctrl''': '''https://huggingface.co/ctrl/resolve/main/config.json'''}




class 			UpperCamelCase_     (			UpperCamelCase):

	"""simple docstring"""





	snake_case__    :  Dict    =      "ctrl"
	snake_case__    :  int    =      ["past_key_values"]
	snake_case__    :  Tuple    =      {
	    "max_position_embeddings": "n_positions",
	    "hidden_size": "n_embd",
	    "num_attention_heads": "n_head",
	    "num_hidden_layers": "n_layer",
	}




	def __init__(			self      :    List[Any]      ,      UpperCAmelCase__      :    Any=2_4_6_5_3_4      ,      UpperCAmelCase__      :    List[Any]=2_5_6      ,      UpperCAmelCase__      :    Optional[int]=1_2_8_0      ,      UpperCAmelCase__      :    Optional[Any]=8_1_9_2      ,      UpperCAmelCase__      :    int=4_8      ,      UpperCAmelCase__      :    Optional[int]=1_6      ,      UpperCAmelCase__      :    Tuple=0.1      ,      UpperCAmelCase__      :    Optional[Any]=0.1      ,      UpperCAmelCase__      :    Any=1E-6      ,      UpperCAmelCase__      :    List[str]=0.02      ,      UpperCAmelCase__      :    Union[str, Any]=True      ,      **UpperCAmelCase__      :    Tuple      ,      )	->     str:
						__SCREAMING_SNAKE_CASE						       =    vocab_size
						__SCREAMING_SNAKE_CASE						       =    n_positions
						__SCREAMING_SNAKE_CASE						       =    n_embd
						__SCREAMING_SNAKE_CASE						       =    n_layer
						__SCREAMING_SNAKE_CASE						       =    n_head
						__SCREAMING_SNAKE_CASE						       =    dff
						__SCREAMING_SNAKE_CASE						       =    resid_pdrop
						__SCREAMING_SNAKE_CASE						       =    embd_pdrop
						__SCREAMING_SNAKE_CASE						       =    layer_norm_epsilon
						__SCREAMING_SNAKE_CASE						       =    initializer_range

						__SCREAMING_SNAKE_CASE						       =    use_cache

						super().__init__(**UpperCAmelCase__       )
