

from ...processing_utils import ProcessorMixin

class 							UpperCAmelCase_						(     __lowercase  ):
							"""simple docstring"""







							UpperCAmelCase__			:		str             =       "SpeechT5FeatureExtractor"
							UpperCAmelCase__			:		Tuple             =       "SpeechT5Tokenizer"


							def __init__(     self			,				_a			,				_a			)       ->       List[str]:
												super().__init__(_a			,				_a			)


							def __call__(     self			,				*_a			,				**_a			)       ->       Dict:
												_a      :       Union[str, Any]   =						kwargs.pop('''audio'''			,				_a			)
												_a      :       Tuple   =						kwargs.pop('''text'''			,				_a			)
												_a      :       Union[str, Any]   =						kwargs.pop('''text_target'''			,				_a			)
												_a      :       Dict   =						kwargs.pop('''audio_target'''			,				_a			)
												_a      :       Union[str, Any]   =						kwargs.pop('''sampling_rate'''			,				_a			)

												if audio is not None and text is not None:
																	raise ValueError(
																	    '''Cannot process both `audio` and `text` inputs. Did you mean `audio_target` or `text_target`?'''			)
												if audio_target is not None and text_target is not None:
																	raise ValueError(
																	    '''Cannot process both `audio_target` and `text_target` inputs. Did you mean `audio` or `text`?'''			)
												if audio is None and audio_target is None and text is None and text_target is None:
																	raise ValueError(
																	    '''You need to specify either an `audio`, `audio_target`, `text`, or `text_target` input to process.'''			)

												if audio is not None:
																	_a      :       int   =						self.feature_extractor(_a			,				*_a			,				sampling_rate=_a			,				**_a			)
												elif text is not None:
																	_a      :       Dict   =						self.tokenizer(_a			,				**_a			)
												else:
																	_a      :       Tuple   =						None

												if audio_target is not None:
																	_a      :       Optional[int]   =						self.feature_extractor(audio_target=_a			,				*_a			,				sampling_rate=_a			,				**_a			)
																	_a      :       str   =						targets['''input_values''']
												elif text_target is not None:
																	_a      :       int   =						self.tokenizer(_a			,				**_a			)
																	_a      :       Optional[Any]   =						targets['''input_ids''']
												else:
																	_a      :       Any   =						None

												if inputs is None:
																	return targets

												if targets is not None:
																	_a      :       int   =						labels

																	_a      :       List[str]   =						targets.get('''attention_mask'''			)
																	if decoder_attention_mask is not None:
																						_a      :       Optional[Any]   =						decoder_attention_mask

												return inputs


							def 							__lowercase							(     self			,				*_a			,				**_a			)       ->       Union[str, Any]:
												_a      :       str   =						kwargs.pop('''input_values'''			,				_a			)
												_a      :       Optional[Any]   =						kwargs.pop('''input_ids'''			,				_a			)
												_a      :       List[str]   =						kwargs.pop('''labels'''			,				_a			)

												if input_values is not None and input_ids is not None:
																	raise ValueError('''Cannot process both `input_values` and `input_ids` inputs.'''			)
												if input_values is None and input_ids is None and labels is None:
																	raise ValueError(
																	    '''You need to specify either an `input_values`, `input_ids`, or `labels` input to be padded.'''			)

												if input_values is not None:
																	_a      :       int   =						self.feature_extractor.pad(_a			,				*_a			,				**_a			)
												elif input_ids is not None:
																	_a      :       List[Any]   =						self.tokenizer.pad(_a			,				**_a			)
												else:
																	_a      :       Tuple   =						None

												if labels is not None:
																	if "input_ids" in labels or (isinstance(_a			,				_a			) and "input_ids" in labels[0]):
																						_a      :       List[Any]   =						self.tokenizer.pad(_a			,				**_a			)
																						_a      :       Any   =						targets['''input_ids''']
																	else:
																						_a      :       Union[str, Any]   =						self.feature_extractor.feature_size
																						_a      :       Any   =						self.feature_extractor.num_mel_bins
																						_a      :       Optional[int]   =						self.feature_extractor.pad(_a			,				*_a			,				**_a			)
																						_a      :       Optional[int]   =						feature_size_hack
																						_a      :       Dict   =						targets['''input_values''']
												else:
																	_a      :       Dict   =						None

												if inputs is None:
																	return targets

												if targets is not None:
																	_a      :       Dict   =						labels

																	_a      :       Union[str, Any]   =						targets.get('''attention_mask'''			)
																	if decoder_attention_mask is not None:
																						_a      :       Any   =						decoder_attention_mask

												return inputs


							def 							__lowercase							(     self			,				*_a			,				**_a			)       ->       List[Any]:
												return self.tokenizer.batch_decode(*_a			,				**_a			)




							def 							__lowercase							(     self			,				*_a			,				**_a			)       ->       Optional[Any]:
												return self.tokenizer.decode(*_a			,				**_a			)






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


a__												=						logging.get_logger(__name__)

a__												=						{
    '''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 							UpperCAmelCase_						(     __lowercase  ):
							"""simple docstring"""







							UpperCAmelCase__			:		Optional[int]             =       "funnel"
							UpperCAmelCase__			:		Tuple             =       {
							    "hidden_size": "d_model",
							    "num_attention_heads": "n_head",
							}


							def __init__(     self			,				_a=3_0_5_2_2			,				_a=[4, 4, 4]			,				_a=None			,				_a=2			,				_a=7_6_8			,				_a=1_2			,				_a=6_4			,				_a=3_0_7_2			,				_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			,				)       ->       List[Any]:
												_a      :       Optional[int]   =						vocab_size
												_a      :       Dict   =						block_sizes
												_a      :       Optional[int]   =						[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."
												_a      :       int   =						num_decoder_layers
												_a      :       List[str]   =						d_model
												_a      :       Optional[Any]   =						n_head
												_a      :       Tuple   =						d_head
												_a      :       Dict   =						d_inner
												_a      :       List[str]   =						hidden_act
												_a      :       int   =						hidden_dropout
												_a      :       Union[str, Any]   =						attention_dropout
												_a      :       Tuple   =						activation_dropout
												_a      :       Optional[Any]   =						initializer_range
												_a      :       Dict   =						initializer_std
												_a      :       Union[str, Any]   =						layer_norm_eps
												assert pooling_type in [
												    "mean",
												    "max",
												], F"""Got {pooling_type} for `pooling_type` but only 'mean' and 'max' are supported."""
												_a      :       Any   =						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      :       Optional[Any]   =						attention_type
												_a      :       int   =						separate_cls
												_a      :       Tuple   =						truncate_seq
												_a      :       List[Any]   =						pool_q_only

												super().__init__(**_a			)


							@property
							def 							__lowercase							(     self			)       ->       Tuple:
												return sum(self.block_sizes			)


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


							@property
							def 							__lowercase							(     self			)       ->       Optional[int]:
												return len(self.block_sizes			)




							@num_blocks.setter
							def 							__lowercase							(     self			,				_a			)       ->       Dict:
												raise NotImplementedError('''This model does not support the setting of `num_blocks`. Please set `block_sizes`.'''			)



