


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


snake_case__      =						logging.get_logger(__name__)

snake_case__      =						{
    '''facebook/s2t-small-librispeech-asr''': (
        '''https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json'''
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech_to_text
}


class 					lowerCAmelCase_ (       UpperCamelCase_):
						lowerCamelCase_         =     'speech_to_text'
						lowerCamelCase_         =     ['past_key_values']
						lowerCamelCase_         =     {'num_attention_heads': 'encoder_attention_heads', 'hidden_size': 'd_model'}




						def __init__(	self						:   Tuple   ,     __A						:   Optional[Any]=10000   ,     __A						:   Union[str, Any]=12   ,     __A						:   Tuple=2048   ,     __A						:   str=4   ,     __A						:   Union[str, Any]=6   ,     __A						:   Tuple=2048   ,     __A						:   int=4   ,     __A						:   Tuple=0.0   ,     __A						:   Dict=0.0   ,     __A						:   Tuple=True   ,     __A						:   Dict=True   ,     __A						:   Any="relu"   ,     __A						:   Any=256   ,     __A						:   str=0.1   ,     __A						:   Union[str, Any]=0.0   ,     __A						:   Any=0.0   ,     __A						:   Tuple=0.02   ,     __A						:   Optional[Any]=2   ,     __A						:   Any=True   ,     __A						:   str=1   ,     __A						:   Any=0   ,     __A						:   List[Any]=2   ,     __A						:   int=6000   ,     __A						:   List[str]=1024   ,     __A						:   List[Any]=2   ,     __A						:   Union[str, Any]=(5, 5)   ,     __A						:   Union[str, Any]=1024   ,     __A						:   str=80   ,     __A						:   Union[str, Any]=1   ,     **__A						:   Optional[int]   ,     )      ->str:






									"""simple docstring"""






									a__ :List[str]						  =    vocab_size
									a__ :Tuple						  =    d_model
									a__ :str						  =    encoder_ffn_dim
									a__ :Optional[int]						  =    encoder_layers
									a__ :Tuple						  =    encoder_attention_heads
									a__ :Dict						  =    decoder_ffn_dim
									a__ :Optional[Any]						  =    decoder_layers
									a__ :str						  =    decoder_attention_heads
									a__ :Optional[int]						  =    dropout
									a__ :str						  =    attention_dropout
									a__ :Tuple						  =    activation_dropout
									a__ :Tuple						  =    activation_function
									a__ :Dict						  =    init_std
									a__ :Any						  =    encoder_layerdrop
									a__ :Union[str, Any]						  =    decoder_layerdrop
									a__ :List[str]						  =    use_cache
									a__ :List[Any]						  =    encoder_layers
									a__ :int						  =    scale_embedding  # scale factor will be sqrt(d_model) if True
									a__ :Union[str, Any]						  =    max_source_positions
									a__ :Union[str, Any]						  =    max_target_positions
									a__ :Any						  =    num_conv_layers
									a__ :Optional[int]						  =    list(__a						)
									a__ :Dict						  =    conv_channels
									a__ :Union[str, Any]						  =    input_feat_per_channel
									a__ :Optional[int]						  =    input_channels

									if len(self.conv_kernel_sizes						) != self.num_conv_layers:
												raise ValueError(
												    "Configuration for convolutional module is incorrect. "
												    "It is required that `len(config.conv_kernel_sizes)` == `config.num_conv_layers` "
												    F'''but is `len(config.conv_kernel_sizes) = {len(self.conv_kernel_sizes						)}`, '''
												    F'''`config.num_conv_layers = {self.num_conv_layers}`.'''						)

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






import os
import time

import numpy as np
import onnxruntime as ort


snake_case__			 =						'''1'''
snake_case__			 =						'''0'''
snake_case__			 =						'''1'''

snake_case__			 =						ort.SessionOptions()
snake_case__			 =						ort.GraphOptimizationLevel.ORT_DISABLE_ALL
print('''Create inference session...''')
snake_case__			 =						['''TensorrtExecutionProvider''', '''CUDAExecutionProvider''']
snake_case__			 =						ort.InferenceSession('''model.onnx''', sess_options=sess_opt, providers=execution_provider)
snake_case__			 =						ort.RunOptions()

snake_case__			 =						128
snake_case__			 =						1
snake_case__			 =						np.ones((batch, sequence), dtype=np.intaa)
snake_case__			 =						np.ones((batch, sequence), dtype=np.intaa)
snake_case__			 =						np.ones((batch, sequence), dtype=np.intaa)

print('''Warm up phase...''')
sess.run(
    None,
    {
        sess.get_inputs()[0].name: input_ids,
        sess.get_inputs()[1].name: attention_mask,
        sess.get_inputs()[2].name: token_type_ids,
    },
    run_options=run_opt,
)

print('''Start inference...''')
snake_case__			 =						time.time()
snake_case__			 =						2000
snake_case__			 =						{}
for iter in range(max_iters):
		snake_case__			 =						sess.run(
		    None,
		    {
		        sess.get_inputs()[0].name: input_ids,
		        sess.get_inputs()[1].name: attention_mask,
		        sess.get_inputs()[2].name: token_type_ids,
		    },
		    run_options=run_opt,
		)
print('''Average Inference Time = {:.3f} ms'''.format((time.time() - start_time) * 1000 / max_iters))


