
import math
from typing import Optional

import numpy as np

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


_A   =			logging.get_logger(__name__)

_A   =			{
    "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__    :							str									=		"encodec"





     def __init__(self				:   Any    ,   _A				:   Dict=[1.5, 3.0, 6.0, 12.0, 24.0]    ,   _A				:   Dict=2_4_0_0_0    ,   _A				:   int=1    ,   _A				:   Optional[int]=False    ,   _A				:   Tuple=None    ,   _A				:   Union[str, Any]=None    ,   _A				:   List[Any]=1_2_8    ,   _A				:   Union[str, Any]=3_2    ,   _A				:   List[str]=1    ,   _A				:   Dict=[8, 5, 4, 2]    ,   _A				:   Dict="weight_norm"    ,   _A				:   Dict=7    ,   _A				:   Optional[Any]=7    ,   _A				:   int=3    ,   _A				:   Optional[int]=2    ,   _A				:   Tuple=True    ,   _A				:   Optional[Any]="reflect"    ,   _A				:   Optional[Any]=2    ,   _A				:   Tuple=2    ,   _A				:   Any=1.0    ,   _A				:   Union[str, Any]=1_0_2_4    ,   _A				:   Optional[int]=None    ,   _A				:   Dict=True    ,   **_A				:   str    ,   )						->						List[Any]:
         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__(**_A       )





     @property
     def 		UpperCAmelCase(self				:   List[Any]       )						->						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				:   List[str]       )						->						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				:   Union[str, Any]       )						->						int:
         snake_case								= np.prod(self.upsampling_ratios       )
         return math.ceil(self.sampling_rate / hop_length       )





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



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


_A   =			logging.get_logger(__name__)

_A   =			{
    "google/realm-cc-news-pretrained-embedder": (
        "https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/config.json"
    ),
    "google/realm-cc-news-pretrained-encoder": (
        "https://huggingface.co/google/realm-cc-news-pretrained-encoder/resolve/main/config.json"
    ),
    "google/realm-cc-news-pretrained-scorer": (
        "https://huggingface.co/google/realm-cc-news-pretrained-scorer/resolve/main/config.json"
    ),
    "google/realm-cc-news-pretrained-openqa": (
        "https://huggingface.co/google/realm-cc-news-pretrained-openqa/aresolve/main/config.json"
    ),
    "google/realm-orqa-nq-openqa": "https://huggingface.co/google/realm-orqa-nq-openqa/resolve/main/config.json",
    "google/realm-orqa-nq-reader": "https://huggingface.co/google/realm-orqa-nq-reader/resolve/main/config.json",
    "google/realm-orqa-wq-openqa": "https://huggingface.co/google/realm-orqa-wq-openqa/resolve/main/config.json",
    "google/realm-orqa-wq-reader": "https://huggingface.co/google/realm-orqa-wq-reader/resolve/main/config.json",
    # See all REALM models at https://huggingface.co/models?filter=realm
}







class 					lowerCamelCase		(  A_  ):
     UpperCAmelCase__    :							str									=		"realm"





     def __init__(self				:   Optional[int]    ,   _A				:   Optional[Any]=3_0_5_2_2    ,   _A				:   Tuple=7_6_8    ,   _A				:   List[str]=1_2_8    ,   _A				:   Optional[Any]=1_2    ,   _A				:   Dict=1_2    ,   _A				:   Tuple=8    ,   _A				:   Dict=3_0_7_2    ,   _A				:   Union[str, Any]="gelu_new"    ,   _A				:   Any=0.1    ,   _A				:   int=0.1    ,   _A				:   Union[str, Any]=5_1_2    ,   _A				:   List[str]=2    ,   _A				:   Any=0.02    ,   _A				:   int=1E-12    ,   _A				:   Tuple=2_5_6    ,   _A				:   Optional[Any]=1_0    ,   _A				:   Any=1E-3    ,   _A				:   int=5    ,   _A				:   int=3_2_0    ,   _A				:   Dict=1_3_3_5_3_7_1_8    ,   _A				:   Any=5_0_0_0    ,   _A				:   Union[str, Any]=1    ,   _A				:   Dict=0    ,   _A				:   int=2    ,   **_A				:   Union[str, Any]    ,   )						->						Optional[Any]:
         super().__init__(pad_token_id=_A    ,   bos_token_id=_A    ,   eos_token_id=_A    ,   **_A       )

         # Common config
         snake_case								= vocab_size
         snake_case								= max_position_embeddings
         snake_case								= hidden_size
         snake_case								= retriever_proj_size
         snake_case								= num_hidden_layers
         snake_case								= num_attention_heads
         snake_case								= num_candidates
         snake_case								= intermediate_size
         snake_case								= hidden_act
         snake_case								= hidden_dropout_prob
         snake_case								= attention_probs_dropout_prob
         snake_case								= initializer_range
         snake_case								= type_vocab_size
         snake_case								= layer_norm_eps

         # Reader config
         snake_case								= span_hidden_size
         snake_case								= max_span_width
         snake_case								= reader_layer_norm_eps
         snake_case								= reader_beam_size
         snake_case								= reader_seq_len

         # Retrieval config
         snake_case								= num_block_records
         snake_case								= searcher_beam_size

