



import math
from typing import Optional

import numpy as np

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


UpperCAmelCase__     = logging.get_logger(__name__)

UpperCAmelCase__     = {
    "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     __lowerCAmelCase					(    A		):
			UpperCamelCase           =  '''encodec'''



			def __init__(		self     :						List[str]				,	A     :						List[str]=[1.5, 3.0, 6.0, 1_2.0, 2_4.0]				,	A     :						Union[str, Any]=2_40_00				,	A     :						Optional[int]=1				,	A     :						Optional[Any]=False				,	A     :						Any=None				,	A     :						Optional[Any]=None				,	A     :						int=1_28				,	A     :						int=32				,	A     :						int=1				,	A     :						Dict=[8, 5, 4, 2]				,	A     :						Optional[int]="weight_norm"				,	A     :						str=7				,	A     :						Optional[int]=7				,	A     :						Union[str, Any]=3				,	A     :						Optional[Any]=2				,	A     :						Optional[Any]=True				,	A     :						Tuple="reflect"				,	A     :						Tuple=2				,	A     :						List[str]=2				,	A     :						Optional[Any]=1.0				,	A     :						Any=10_24				,	A     :						Union[str, Any]=None				,	A     :						List[Any]=True				,	**A     :						Any				,	)     ->					Optional[Any]:



						"""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__(**A)



			@property
			def 					_lowerCamelCase (		self     :						int)     ->					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     :						Any)     ->					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"""






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



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



						"""simple docstring"""






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





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


UpperCAmelCase__     = {
    "configuration_ctrl": ["CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP", "CTRLConfig"],
    "tokenization_ctrl": ["CTRLTokenizer"],
}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCAmelCase__     = [
							    "CTRL_PRETRAINED_MODEL_ARCHIVE_LIST",
							    "CTRLForSequenceClassification",
							    "CTRLLMHeadModel",
							    "CTRLModel",
							    "CTRLPreTrainedModel",
							]

try:
							if not is_tf_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCAmelCase__     = [
							    "TF_CTRL_PRETRAINED_MODEL_ARCHIVE_LIST",
							    "TFCTRLForSequenceClassification",
							    "TFCTRLLMHeadModel",
							    "TFCTRLModel",
							    "TFCTRLPreTrainedModel",
							]


if TYPE_CHECKING:
							from .configuration_ctrl import CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRLConfig
							from .tokenization_ctrl import CTRLTokenizer

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_ctrl import (
														    CTRL_PRETRAINED_MODEL_ARCHIVE_LIST,
														    CTRLForSequenceClassification,
														    CTRLLMHeadModel,
														    CTRLModel,
														    CTRLPreTrainedModel,
														)

							try:
														if not is_tf_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_tf_ctrl import (
														    TF_CTRL_PRETRAINED_MODEL_ARCHIVE_LIST,
														    TFCTRLForSequenceClassification,
														    TFCTRLLMHeadModel,
														    TFCTRLModel,
														    TFCTRLPreTrainedModel,
														)

else:
							import sys

							UpperCAmelCase__     = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
