





'''simple docstring'''







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


_lowercase       						=			logging.get_logger(__name__)

_lowercase       						=			{
    '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 			_lowercase						(       __a					):
     _UpperCAmelCase										=					'''funnel'''
     _UpperCAmelCase										=					{
         '''hidden_size''': '''d_model''',
         '''num_attention_heads''': '''n_head''',
     }







     def __init__( self    ,   A__=3_05_22    ,   A__=[4, 4, 4]    ,   A__=None    ,   A__=2    ,   A__=7_68    ,   A__=12    ,   A__=64    ,   A__=30_72    ,   A__="gelu_new"    ,   A__=0.1    ,   A__=0.1    ,   A__=0.0    ,   A__=0.1    ,   A__=None    ,   A__=1e-9    ,   A__="mean"    ,   A__="relative_shift"    ,   A__=True    ,   A__=True    ,   A__=True    ,   **A__    ,   ) ->	str:
      snake_case				=			vocab_size
      snake_case				=			block_sizes
      snake_case				=			[1] * len(A__    ) if block_repeats is None else block_repeats
      assert len(A__    ) == len(
          self.block_repeats    ), "`block_sizes` and `block_repeats` should have the same length."
      snake_case				=			num_decoder_layers
      snake_case				=			d_model
      snake_case				=			n_head
      snake_case				=			d_head
      snake_case				=			d_inner
      snake_case				=			hidden_act
      snake_case				=			hidden_dropout
      snake_case				=			attention_dropout
      snake_case				=			activation_dropout
      snake_case				=			initializer_range
      snake_case				=			initializer_std
      snake_case				=			layer_norm_eps
      assert pooling_type in [
          "mean",
          "max",
      ], F"""Got {pooling_type} for `pooling_type` but only 'mean' and 'max' are supported."""
      snake_case				=			pooling_type
      assert attention_type in [
          "relative_shift",
          "factorized",
      ], F"""Got {attention_type} for `attention_type` but only 'relative_shift' and 'factorized' are supported."""
      snake_case				=			attention_type
      snake_case				=			separate_cls
      snake_case				=			truncate_seq
      snake_case				=			pool_q_only

      super().__init__(**A__    )







     @property
     def     UpperCamelCase			( self    ) ->	Any:
      return sum(self.block_sizes    )







     @num_hidden_layers.setter
     def     UpperCamelCase			( self    ,   A__    ) ->	Tuple:
      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    ,   A__    ) ->	List[str]:
      raise NotImplementedError('''This model does not support the setting of `num_blocks`. Please set `block_sizes`.'''    )








'''simple docstring'''







from ...processing_utils import ProcessorMixin
class 			_lowercase						(       __a					):
     _UpperCAmelCase										=					'''WhisperFeatureExtractor'''
     _UpperCAmelCase										=					'''WhisperTokenizer'''







     def __init__( self    ,   A__    ,   A__    ) ->	Optional[Any]:
      super().__init__(A__    ,   A__    )
      snake_case				=			self.feature_extractor
      snake_case				=			False







     def     UpperCamelCase			( self    ,   A__=None    ,   A__=None    ,   A__=True    ) ->	Union[str, Any]:
      return self.tokenizer.get_decoder_prompt_ids(task=A__    ,   language=A__    ,   no_timestamps=A__    )







     def __call__( self    ,   *A__    ,   **A__    ) ->	Dict:
      # For backward compatibility
      if self._in_target_context_manager:
       return self.current_processor(*A__    ,   **A__    )

      snake_case				=			kwargs.pop('''audio'''    ,   A__    )
      snake_case				=			kwargs.pop('''sampling_rate'''    ,   A__    )
      snake_case				=			kwargs.pop('''text'''    ,   A__    )
      if len(A__    ) > 0:
       snake_case				=			args[0]
       snake_case				=			args[1:]

      if audio is None and text is None:
       raise ValueError('''You need to specify either an `audio` or `text` input to process.'''    )

      if audio is not None:
       snake_case				=			self.feature_extractor(A__    ,   *A__    ,   sampling_rate=A__    ,   **A__    )
      if text is not None:
       snake_case				=			self.tokenizer(A__    ,   **A__    )

      if text is None:
       return inputs

      elif audio is None:
       return encodings
      else:
       snake_case				=			encodings['''input_ids''']
       return inputs







     def     UpperCamelCase			( self    ,   *A__    ,   **A__    ) ->	Optional[Any]:
      return self.tokenizer.batch_decode(*A__    ,   **A__    )







     def     UpperCamelCase			( self    ,   *A__    ,   **A__    ) ->	str:
      return self.tokenizer.decode(*A__    ,   **A__    )







     def     UpperCamelCase			( self    ,   A__    ,   A__="np"    ) ->	Optional[Any]:
      return self.tokenizer.get_prompt_ids(A__    ,   return_tensors=A__    )

