





import numpy as np

from transformers import Pipeline





def       _UpperCamelCase       (a__				:Tuple    ) ->    List[Any]:






							"""simple docstring"""





							UpperCamelCase__			       =     np.max(a__				,     axis=-1				,     keepdims=a__    )
							UpperCamelCase__			       =     np.exp(outputs - maxes    )
							return shifted_exp / shifted_exp.sum(axis=-1				,     keepdims=a__    )

class     __SCREAMING_SNAKE_CASE   (       _a    ):






							def 			_lowerCamelCase						(  self					,	**__lowerCAmelCase					):
														UpperCamelCase__			       =     {}
														if "second_text" in kwargs:
																					UpperCamelCase__			       =     kwargs["""second_text"""]
														return preprocess_kwargs, {}, {}






							def 			_lowerCamelCase						(  self					,	__lowerCAmelCase					,	__lowerCAmelCase=None					):
														return self.tokenizer(__lowerCAmelCase					,	text_pair=__lowerCAmelCase					,	return_tensors=self.framework					)






							def 			_lowerCamelCase						(  self					,	__lowerCAmelCase					):
														return self.model(**__lowerCAmelCase					)







							def 			_lowerCamelCase						(  self					,	__lowerCAmelCase					):
														UpperCamelCase__			       =     model_outputs.logits[0].numpy()
														UpperCamelCase__			       =     softmax(__lowerCAmelCase					)

														UpperCamelCase__			       =     np.argmax(__lowerCAmelCase					)
														UpperCamelCase__			       =     self.model.config.idalabel[best_class]
														UpperCamelCase__			       =     probabilities[best_class].item()
														UpperCamelCase__			       =     logits.tolist()
														return {"label": label, "score": score, "logits": logits}











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


UpperCamelCase__     =	logging.get_logger(__name__)

UpperCamelCase__     =	{
    "facebook/s2t-wav2vec2-large-en-de": (
        "https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json"
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech2text2
}

class     __SCREAMING_SNAKE_CASE   (       _a    ):
							snake_case       : Dict         =    """speech_to_text_2"""
							snake_case       : List[Any]         =    ["""past_key_values"""]
							snake_case       : List[str]         =    {"""num_attention_heads""": """decoder_attention_heads""", """hidden_size""": """d_model"""}






							def __init__(  self					,	__lowerCAmelCase=10000					,	__lowerCAmelCase=6					,	__lowerCAmelCase=2048					,	__lowerCAmelCase=4					,	__lowerCAmelCase=0.0					,	__lowerCAmelCase=True					,	__lowerCAmelCase="relu"					,	__lowerCAmelCase=256					,	__lowerCAmelCase=0.1					,	__lowerCAmelCase=0.0					,	__lowerCAmelCase=0.0					,	__lowerCAmelCase=0.02					,	__lowerCAmelCase=2					,	__lowerCAmelCase=True					,	__lowerCAmelCase=1					,	__lowerCAmelCase=0					,	__lowerCAmelCase=2					,	__lowerCAmelCase=1024					,	**__lowerCAmelCase					,	):
														UpperCamelCase__			       =     vocab_size
														UpperCamelCase__			       =     d_model
														UpperCamelCase__			       =     decoder_ffn_dim
														UpperCamelCase__			       =     decoder_layers
														UpperCamelCase__			       =     decoder_attention_heads
														UpperCamelCase__			       =     dropout
														UpperCamelCase__			       =     attention_dropout
														UpperCamelCase__			       =     activation_dropout
														UpperCamelCase__			       =     activation_function
														UpperCamelCase__			       =     init_std
														UpperCamelCase__			       =     decoder_layerdrop
														UpperCamelCase__			       =     use_cache
														UpperCamelCase__			       =     decoder_layers
														UpperCamelCase__			       =     scale_embedding  # scale factor will be sqrt(d_model) if True
														UpperCamelCase__			       =     max_target_positions

														super().__init__(
														    pad_token_id=__lowerCAmelCase					,	bos_token_id=__lowerCAmelCase					,	eos_token_id=__lowerCAmelCase					,	decoder_start_token_id=__lowerCAmelCase					,	**__lowerCAmelCase					,	)




