






"""simple docstring"""
import os
import time

import numpy as np
import onnxruntime as ort


lowerCamelCase_       			=   '''1'''
lowerCamelCase_       			=   '''0'''
lowerCamelCase_       			=   '''1'''

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

lowerCamelCase_       			=   128
lowerCamelCase_       			=   1
lowerCamelCase_       			=   np.ones((batch, sequence), dtype=np.intaa)
lowerCamelCase_       			=   np.ones((batch, sequence), dtype=np.intaa)
lowerCamelCase_       			=   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...''')
lowerCamelCase_       			=   time.time()
lowerCamelCase_       			=   2000
lowerCamelCase_       			=   {}
for iter in range(max_iters):
			lowerCamelCase_       			=   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))











"""simple docstring"""
from ..utils import DummyObject, requires_backends







class     UpperCamelCase_ (metaclass=__A  ):
	__magic_name__			   =       ['''onnx''']





	def __init__(   self      :				List[Any]			,			*lowerCAmelCase_      :				Dict			,			**lowerCAmelCase_      :				Dict		)		->    Dict:
				requires_backends(self			,			["onnx"]		)





	@classmethod
	def   _SCREAMING_SNAKE_CASE   (   cls      :				Optional[Any]			,			*lowerCAmelCase_      :				Dict			,			**lowerCAmelCase_      :				Union[str, Any]		)		->    int:
				requires_backends(cls			,			["onnx"]		)





	@classmethod
	def   _SCREAMING_SNAKE_CASE   (   cls      :				str			,			*lowerCAmelCase_      :				Optional[Any]			,			**lowerCAmelCase_      :				str		)		->    Optional[Any]:
				requires_backends(cls			,			["onnx"]		)



