code: def compute_onnx_latency(
      xs: List[Tuple[np.array]],
      model: str,
      device: Device,
      steps: int = 100,
      warmup_steps: int = 10,
  ) -> Tuple[float, List[float]]:
      """Compute the latency associated with the ONNX model.
  
      Args:
          xs (List[Tuple[np.array]]): List of tuples containing the
              inputs (a single batch for the model).
          model (str): ONNX model path.
          device (Device): Device where computing the latency.
          steps (int, optional): Number of input data to be used to compute the
              latency of the model. It must be a number <= len(xs). Default: 100.
          warmup_steps (int, optional): Number of input data to be used to warm
              up the model. It must be a number <= len(xs). Default: 10.
  
      Returns:
          Float: Average latency.
          List[Float]: List of latencies obtained.
      """
      from nebullvm.optional_modules.onnxruntime import (
          onnxruntime as ort,
      )
  
      input_names = get_input_names(model)
      output_names = get_output_names(model)
  
      if (
          device.type is DeviceType.GPU
          and len(ONNX_PROVIDERS["cuda"]) == 3
      ):
          ONNX_PROVIDERS["cuda"][1] = (
              "CUDAExecutionProvider",
              {
                  "device_id": device.idx,
              },
          )
  
      model = ort.InferenceSession(
          model,
          providers=ONNX_PROVIDERS["cuda"][1:]
          if device.type is DeviceType.GPU
          else ONNX_PROVIDERS["cpu"],
      )
  
      latencies = []
      for i in range(warmup_steps):
          inputs = {
              name: array for name, array in zip(input_names, xs[i])
          }
          _ = model.run(output_names=output_names, input_feed=inputs)
      for i in range(steps):
          inputs = {
              name: array for name, array in zip(input_names, xs[i])
          }
          starting_time = time.time()
          _ = model.run(output_names=output_names, input_feed=inputs)
          latencies.append(time.time() - starting_time)
      latency = np.mean(latencies)
      return latency, latencies
  
file_path: nebuly/optimization/nebullvm/nebullvm/operations/measures/utils.py
imports: import time
  from typing import Tuple, List, Union, Any
  import numpy
  from loguru import logger
  from nebullvm.config import ONNX_PROVIDERS
  from nebullvm.core.models import Device, DeviceType
  from nebullvm.operations.inference_learners.base import BaseInferenceLearner
  from nebullvm.optional_modules.tensorflow import tensorflow
  from nebullvm.optional_modules.torch import torch, Module
  from nebullvm.tools.data import DataManager
  from nebullvm.tools.onnx import convert_to_numpy, get_input_names, get_output_names
label_desc: Use image node_id 3 for calling a global function with example usage: compute_onnx_latency(xs, model, device, steps, warmup_steps) and returns: latency,  latencies