






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


lowerCAmelCase_	:    int            =      logging.get_logger(__name__)

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





class   UpperCamelCase_ (       a_  ):
  _A       :					Optional[Any]				=	'align_text_model'



  def __init__(      self ,		snake_case__=3_05_22 ,		snake_case__=7_68 ,		snake_case__=12 ,		snake_case__=12 ,		snake_case__=30_72 ,		snake_case__="gelu" ,		snake_case__=0.1 ,		snake_case__=0.1 ,		snake_case__=5_12 ,		snake_case__=2 ,		snake_case__=0.02 ,		snake_case__=1e-12 ,		snake_case__=0 ,		snake_case__="absolute" ,		snake_case__=True ,		**snake_case__ ,		)			->			Union[str, Any]:



         """simple docstring"""





         super().__init__(**snake_case__				)

         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 		UpperCamelCase_				(      cls ,		snake_case__ ,		**snake_case__				)			->			"PretrainedConfig":



         """simple docstring"""





         cls._set_token_in_kwargs(snake_case__				)

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

         # 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(snake_case__ ,		**snake_case__				)





class   UpperCamelCase_ (       a_  ):
  _A       :					int				=	'align_vision_model'



  def __init__(      self ,		snake_case__ = 3 ,		snake_case__ = 6_00 ,		snake_case__ = 2.0 ,		snake_case__ = 3.1 ,		snake_case__ = 8 ,		snake_case__ = [3, 3, 5, 3, 5, 5, 3] ,		snake_case__ = [32, 16, 24, 40, 80, 1_12, 1_92] ,		snake_case__ = [16, 24, 40, 80, 1_12, 1_92, 3_20] ,		snake_case__ = [] ,		snake_case__ = [1, 2, 2, 2, 1, 2, 1] ,		snake_case__ = [1, 2, 2, 3, 3, 4, 1] ,		snake_case__ = [1, 6, 6, 6, 6, 6, 6] ,		snake_case__ = 0.25 ,		snake_case__ = "swish" ,		snake_case__ = 25_60 ,		snake_case__ = "mean" ,		snake_case__ = 0.02 ,		snake_case__ = 0.001 ,		snake_case__ = 0.99 ,		snake_case__ = 0.2 ,		**snake_case__ ,		)			->			Dict:



         """simple docstring"""





         super().__init__(**snake_case__				)

         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(snake_case__				) * 4



  @classmethod
  def 		UpperCamelCase_				(      cls ,		snake_case__ ,		**snake_case__				)			->			"PretrainedConfig":



         """simple docstring"""





         cls._set_token_in_kwargs(snake_case__				)

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

         # 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(snake_case__ ,		**snake_case__				)





class   UpperCamelCase_ (       a_  ):
  _A       :					str				=	'align'
  _A       :					Optional[Any]				=	True



  def __init__(      self ,		snake_case__=None ,		snake_case__=None ,		snake_case__=6_40 ,		snake_case__=1.0 ,		snake_case__=0.02 ,		**snake_case__ ,		)			->			Tuple:



         """simple docstring"""





         super().__init__(**snake_case__				)

         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(**snake_case__				)
         UpperCAmelCase	    =			AlignVisionConfig(**snake_case__				)

         UpperCAmelCase	    =			projection_dim
         UpperCAmelCase	    =			temperature_init_value
         UpperCAmelCase	    =			initializer_range



  @classmethod
  def 		UpperCamelCase_				(      cls ,		snake_case__ ,		snake_case__ ,		**snake_case__				)			->			Optional[int]:



         """simple docstring"""





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



  def 		UpperCamelCase_				(      self				)			->			Optional[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


lowerCAmelCase_	:    List[Any]            =      logging.get_logger(__name__)

lowerCAmelCase_	:    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_ (       a_  ):
  _A       :					Dict				=	'encodec'



  def __init__(      self ,		snake_case__=[1.5, 3.0, 6.0, 12.0, 24.0] ,		snake_case__=2_40_00 ,		snake_case__=1 ,		snake_case__=False ,		snake_case__=None ,		snake_case__=None ,		snake_case__=1_28 ,		snake_case__=32 ,		snake_case__=1 ,		snake_case__=[8, 5, 4, 2] ,		snake_case__="weight_norm" ,		snake_case__=7 ,		snake_case__=7 ,		snake_case__=3 ,		snake_case__=2 ,		snake_case__=True ,		snake_case__="reflect" ,		snake_case__=2 ,		snake_case__=2 ,		snake_case__=1.0 ,		snake_case__=10_24 ,		snake_case__=None ,		snake_case__=True ,		**snake_case__ ,		)			->			List[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__(**snake_case__				)



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



         """simple docstring"""





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



  @property
  def 		UpperCamelCase_				(      self				)			->			int:



         """simple docstring"""





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