

'''simple docstring'''





import os
import time

import numpy as np
import onnxruntime as ort


_UpperCAmelCase	:     List[Any]		       = "1"
_UpperCAmelCase	:     Optional[int]		       = "0"
_UpperCAmelCase	:     str		       = "1"

_UpperCAmelCase	:     str		       = ort.SessionOptions()
_UpperCAmelCase	:     str		       = ort.GraphOptimizationLevel.ORT_DISABLE_ALL
print("""Create inference session...""")
_UpperCAmelCase	:     Union[str, Any]		       = ["TensorrtExecutionProvider", "CUDAExecutionProvider"]
_UpperCAmelCase	:     Optional[int]		       = ort.InferenceSession("""model.onnx""", sess_options=sess_opt, providers=execution_provider)
_UpperCAmelCase	:     str		       = ort.RunOptions()

_UpperCAmelCase	:     Optional[int]		       = 128
_UpperCAmelCase	:     str		       = 1
_UpperCAmelCase	:     List[str]		       = np.ones((batch, sequence), dtype=np.intaa)
_UpperCAmelCase	:     List[Any]		       = np.ones((batch, sequence), dtype=np.intaa)
_UpperCAmelCase	:     List[str]		       = 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...""")
_UpperCAmelCase	:     int		       = time.time()
_UpperCAmelCase	:     Any		       = 2000
_UpperCAmelCase	:     Union[str, Any]		       = {}
for iter in range(max_iters):
					_UpperCAmelCase	:     Union[str, Any]		       = 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))







def       __lowerCamelCase			(				UpperCamelCase__   ):







							'''simple docstring'''






							if not nums:  # Makes sure that the list is not empty
														raise ValueError('List is empty'   )

							snake_case_           =					sum(UpperCamelCase__   ) / len(UpperCamelCase__   )  # Calculate the average
							return sum(abs(x - average   ) for x in nums   ) / len(UpperCamelCase__   )


if __name__ == "__main__":
					import doctest

					doctest.testmod()




