code: def compute_torch_latency(
      xs: List[Tuple[torch.Tensor]],
      model: Module,
      device: Device,
      steps: int = 100,
      warmup_steps: int = 10,
  ) -> Tuple[float, List[float]]:
      """Compute the latency associated with the torch model.
  
      Args:
          xs (List[Tuple[torch.Tensor]]): List of tuples containing the
              input tensors (a single batch for the model).
          model (Module): Torch model.
          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.
      """
      if device.type is not DeviceType.TPU:
          xs = [
              tuple(t.to(device.to_torch_format()) for t in tensors)
              for tensors in xs
          ]
          model = model.to(device.to_torch_format())
      model.eval()
      latencies = []
      with torch.no_grad():
          for i in range(warmup_steps):
              _ = model.forward(*xs[i])
          for i in range(steps):
              starting_time = time.time()
              _ = model.forward(*xs[i])
              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 1 for calling a global function with example usage: compute_torch_latency(xs, model, device, steps, warmup_steps) and returns: latency,  latencies