




'''simple docstring'''





from __future__ import annotations

import typing
from collections.abc import Iterable

import numpy as np

SCREAMING_SNAKE_CASE__      					=     typing.Union[Iterable[float], Iterable[int], np.ndarray]  # noqa: UP007
SCREAMING_SNAKE_CASE__      					=     typing.Union[np.floataa, int, float]  # noqa: UP007




def        lowerCamelCase  (				_snake_case  :						Optional[Any]     ,_snake_case  :						str       ):





    '''simple docstring'''


    return np.sqrt(np.sum((np.asarray(__SCREAMING_SNAKE_CASE       ) - np.asarray(__SCREAMING_SNAKE_CASE       )) ** 2       )       )




def        lowerCamelCase  (				_snake_case  :						List[Any]     ,_snake_case  :						int       ):





    '''simple docstring'''


    return sum((va - va) ** 2 for va, va in zip(__SCREAMING_SNAKE_CASE     ,__SCREAMING_SNAKE_CASE       )       ) ** (1 / 2)


if __name__ == "__main__":




 def        lowerCamelCase  (				):





     '''simple docstring'''


     from timeit import timeit

     print("Without Numpy"       )
     print(
         timeit(
             "euclidean_distance_no_np([1, 2, 3], [4, 5, 6])"     ,number=10_000     ,globals=globals()     ,)       )
     print("With Numpy"       )
     print(
         timeit(
             "euclidean_distance([1, 2, 3], [4, 5, 6])"     ,number=10_000     ,globals=globals()     ,)       )



 benchmark()









'''simple docstring'''





import os
import time

import numpy as np
import onnxruntime as ort


SCREAMING_SNAKE_CASE__      					=     "1"
SCREAMING_SNAKE_CASE__      					=     "0"
SCREAMING_SNAKE_CASE__      					=     "1"

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

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




