


'''simple docstring'''




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


UpperCAmelCase_      :		str          =		logging.get_logger(__name__)

UpperCAmelCase_      :		Any          =		{
    "funnel-transformer/small": "https://huggingface.co/funnel-transformer/small/resolve/main/config.json",
    "funnel-transformer/small-base": "https://huggingface.co/funnel-transformer/small-base/resolve/main/config.json",
    "funnel-transformer/medium": "https://huggingface.co/funnel-transformer/medium/resolve/main/config.json",
    "funnel-transformer/medium-base": "https://huggingface.co/funnel-transformer/medium-base/resolve/main/config.json",
    "funnel-transformer/intermediate": (
        "https://huggingface.co/funnel-transformer/intermediate/resolve/main/config.json"
    ),
    "funnel-transformer/intermediate-base": (
        "https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/config.json"
    ),
    "funnel-transformer/large": "https://huggingface.co/funnel-transformer/large/resolve/main/config.json",
    "funnel-transformer/large-base": "https://huggingface.co/funnel-transformer/large-base/resolve/main/config.json",
    "funnel-transformer/xlarge": "https://huggingface.co/funnel-transformer/xlarge/resolve/main/config.json",
    "funnel-transformer/xlarge-base": "https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/config.json",
}







class 					a			(				snake_case__  ):
 '''simple docstring'''




 __lowerCAmelCase						: Any							  =		"""funnel"""
 __lowerCAmelCase						: Optional[Any]							  =		{
     """hidden_size""": """d_model""",
     """num_attention_heads""": """n_head""",
 }




 def __init__(    self		,      lowerCamelCase_=3_0_5_2_2		,      lowerCamelCase_=[4, 4, 4]		,      lowerCamelCase_=None		,      lowerCamelCase_=2		,      lowerCamelCase_=7_6_8		,      lowerCamelCase_=1_2		,      lowerCamelCase_=6_4		,      lowerCamelCase_=3_0_7_2		,      lowerCamelCase_="gelu_new"		,      lowerCamelCase_=0.1		,      lowerCamelCase_=0.1		,      lowerCamelCase_=0.0		,      lowerCamelCase_=0.1		,      lowerCamelCase_=None		,      lowerCamelCase_=1e-9		,      lowerCamelCase_="mean"		,      lowerCamelCase_="relative_shift"		,      lowerCamelCase_=True		,      lowerCamelCase_=True		,      lowerCamelCase_=True		,      **lowerCamelCase_		,      )      ->    Dict:
    _a					:  Dict						=  vocab_size
    _a					:  List[Any]						=  block_sizes
    _a					:  Any						=  [1] * len(lowerCamelCase_      ) if block_repeats is None else block_repeats
    assert len(lowerCamelCase_      ) == len(
        self.block_repeats      ), "`block_sizes` and `block_repeats` should have the same length."
    _a					:  Optional[int]						=  num_decoder_layers
    _a					:  Optional[Any]						=  d_model
    _a					:  Tuple						=  n_head
    _a					:  List[str]						=  d_head
    _a					:  Any						=  d_inner
    _a					:  Tuple						=  hidden_act
    _a					:  List[Any]						=  hidden_dropout
    _a					:  int						=  attention_dropout
    _a					:  int						=  activation_dropout
    _a					:  Any						=  initializer_range
    _a					:  int						=  initializer_std
    _a					:  int						=  layer_norm_eps
    assert pooling_type in [
        "mean",
        "max",
    ], F'''Got {pooling_type} for `pooling_type` but only \'mean\' and \'max\' are supported.'''
    _a					:  List[str]						=  pooling_type
    assert attention_type in [
        "relative_shift",
        "factorized",
    ], F'''Got {attention_type} for `attention_type` but only \'relative_shift\' and \'factorized\' are supported.'''
    _a					:  Any						=  attention_type
    _a					:  Dict						=  separate_cls
    _a					:  Any						=  truncate_seq
    _a					:  Tuple						=  pool_q_only

    super().__init__(**lowerCamelCase_      )




 @property
 def   __UpperCamelCase   (    self      )      ->    str:
    return sum(self.block_sizes      )




 @num_hidden_layers.setter
 def   __UpperCamelCase   (    self		,      lowerCamelCase_      )      ->    List[str]:
    raise NotImplementedError(
        'This model does not support the setting of `num_hidden_layers`. Please set `block_sizes`.'      )




 @property
 def   __UpperCamelCase   (    self      )      ->    Tuple:
    return len(self.block_sizes      )




 @num_blocks.setter
 def   __UpperCamelCase   (    self		,      lowerCamelCase_      )      ->    Optional[Any]:
    raise NotImplementedError('This model does not support the setting of `num_blocks`. Please set `block_sizes`.'      )






'''simple docstring'''




from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding







class 					a			(				snake_case__  ):
 '''simple docstring'''




 __lowerCAmelCase						: Optional[int]							  =		"""ClapFeatureExtractor"""
 __lowerCAmelCase						: str							  =		("""RobertaTokenizer""", """RobertaTokenizerFast""")




 def __init__(    self		,      lowerCamelCase_		,      lowerCamelCase_      )      ->    Union[str, Any]:
    super().__init__(lowerCamelCase_		,      lowerCamelCase_      )




 def __call__(    self		,      lowerCamelCase_=None		,      lowerCamelCase_=None		,      lowerCamelCase_=None		,      **lowerCamelCase_      )      ->    List[Any]:
    _a					:  Any						=  kwargs.pop('sampling_rate'		,      lowerCamelCase_      )

    if text is None and audios is None:
       raise ValueError('You have to specify either text or audios. Both cannot be none.'      )

    if text is not None:
       _a					:  Union[str, Any]						=  self.tokenizer(lowerCamelCase_		,      return_tensors=lowerCamelCase_		,      **lowerCamelCase_      )

    if audios is not None:
       _a					:  List[str]						=  self.feature_extractor(
           lowerCamelCase_		,      sampling_rate=lowerCamelCase_		,      return_tensors=lowerCamelCase_		,      **lowerCamelCase_      )

    if text is not None and audios is not None:
       _a					:  List[Any]						=  audio_features.input_features
       return encoding
    elif text is not None:
       return encoding
    else:
       return BatchEncoding(data=dict(**lowerCamelCase_      )		,      tensor_type=lowerCamelCase_      )




 def   __UpperCamelCase   (    self		,      *lowerCamelCase_		,      **lowerCamelCase_      )      ->    Tuple:
    return self.tokenizer.batch_decode(*lowerCamelCase_		,      **lowerCamelCase_      )




 def   __UpperCamelCase   (    self		,      *lowerCamelCase_		,      **lowerCamelCase_      )      ->    List[str]:
    return self.tokenizer.decode(*lowerCamelCase_		,      **lowerCamelCase_      )




 @property
 def   __UpperCamelCase   (    self      )      ->    Tuple:
    _a					:  Dict						=  self.tokenizer.model_input_names
    _a					:  Tuple						=  self.feature_extractor.model_input_names
    return list(dict.fromkeys(tokenizer_input_names + feature_extractor_input_names      )      )


