





"""simple docstring"""





import math
from typing import Optional

import numpy as np

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


SCREAMING_SNAKE_CASE__   =  logging.get_logger(__name__)

SCREAMING_SNAKE_CASE__   =  {
    "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 						lowercase   (   _UpperCAmelCase   ):
      _SCREAMING_SNAKE_CASE							      = 'encodec'





      def __init__(			self ,		lowercase=[1.5, 3.0, 6.0, 12.0, 24.0] ,		lowercase=24_000 ,		lowercase=1 ,		lowercase=False ,		lowercase=None ,		lowercase=None ,		lowercase=128 ,		lowercase=32 ,		lowercase=1 ,		lowercase=[8, 5, 4, 2] ,		lowercase="weight_norm" ,		lowercase=7 ,		lowercase=7 ,		lowercase=3 ,		lowercase=2 ,		lowercase=True ,		lowercase="reflect" ,		lowercase=2 ,		lowercase=2 ,		lowercase=1.0 ,		lowercase=1_024 ,		lowercase=None ,		lowercase=True ,		**lowercase ,		)						->	Union[str, Any]:
            lowerCAmelCase    		=			target_bandwidths
            lowerCAmelCase    		=			sampling_rate
            lowerCAmelCase    		=			audio_channels
            lowerCAmelCase    		=			normalize
            lowerCAmelCase    		=			chunk_length_s
            lowerCAmelCase    		=			overlap
            lowerCAmelCase    		=			hidden_size
            lowerCAmelCase    		=			num_filters
            lowerCAmelCase    		=			num_residual_layers
            lowerCAmelCase    		=			upsampling_ratios
            lowerCAmelCase    		=			norm_type
            lowerCAmelCase    		=			kernel_size
            lowerCAmelCase    		=			last_kernel_size
            lowerCAmelCase    		=			residual_kernel_size
            lowerCAmelCase    		=			dilation_growth_rate
            lowerCAmelCase    		=			use_causal_conv
            lowerCAmelCase    		=			pad_mode
            lowerCAmelCase    		=			compress
            lowerCAmelCase    		=			num_lstm_layers
            lowerCAmelCase    		=			trim_right_ratio
            lowerCAmelCase    		=			codebook_size
            lowerCAmelCase    		=			codebook_dim if codebook_dim is not None else hidden_size
            lowerCAmelCase    		=			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        _snake_case     (			self					)						->	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					)						->	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					)						->	int:
            lowerCAmelCase    		=			np.prod(self.upsampling_ratios					)
            return math.ceil(self.sampling_rate / hop_length					)





      @property
      def        _snake_case     (			self					)						->	int:
            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__   =  logging.get_logger(__name__)

SCREAMING_SNAKE_CASE__   =  {
    "facebook/s2t-wav2vec2-large-en-de": (
        "https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json"
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech2text2
}

class 						lowercase   (   _UpperCAmelCase   ):
      _SCREAMING_SNAKE_CASE							      = 'speech_to_text_2'
      _SCREAMING_SNAKE_CASE							      = ['past_key_values']
      _SCREAMING_SNAKE_CASE							      = {'num_attention_heads': 'decoder_attention_heads', 'hidden_size': 'd_model'}





      def __init__(			self ,		lowercase=10_000 ,		lowercase=6 ,		lowercase=2_048 ,		lowercase=4 ,		lowercase=0.0 ,		lowercase=True ,		lowercase="relu" ,		lowercase=256 ,		lowercase=0.1 ,		lowercase=0.0 ,		lowercase=0.0 ,		lowercase=0.02 ,		lowercase=2 ,		lowercase=True ,		lowercase=1 ,		lowercase=0 ,		lowercase=2 ,		lowercase=1_024 ,		**lowercase ,		)						->	Optional[int]:
            lowerCAmelCase    		=			vocab_size
            lowerCAmelCase    		=			d_model
            lowerCAmelCase    		=			decoder_ffn_dim
            lowerCAmelCase    		=			decoder_layers
            lowerCAmelCase    		=			decoder_attention_heads
            lowerCAmelCase    		=			dropout
            lowerCAmelCase    		=			attention_dropout
            lowerCAmelCase    		=			activation_dropout
            lowerCAmelCase    		=			activation_function
            lowerCAmelCase    		=			init_std
            lowerCAmelCase    		=			decoder_layerdrop
            lowerCAmelCase    		=			use_cache
            lowerCAmelCase    		=			decoder_layers
            lowerCAmelCase    		=			scale_embedding  # scale factor will be sqrt(d_model) if True
            lowerCAmelCase    		=			max_target_positions

            super().__init__(
                pad_token_id=lowercase ,		bos_token_id=lowercase ,		eos_token_id=lowercase ,		decoder_start_token_id=lowercase ,		**lowercase ,		)






