code: def latency_calculate_helper(iterrun, baseline_time, func, *args):
      """
      A simple helper to calculate average latency
      """
      # test run two times for more accurate latency
      for i in range(2):
          func(*args)
      start_time = time.perf_counter()
      time_list = []
      for i in range(iterrun):
          st = time.perf_counter()
          func(*args)
          end = time.perf_counter()
          time_list.append(end - st)
          # if three samples cost more than 4x time than baseline model, prune it
          if i == 2 and end - start_time > 12 * baseline_time:
              return np.mean(time_list) * 1000, False
          # at least need 10 iters and try to control calculation
          # time less than 10s
          if i + 1 >= min(iterrun, 10) and (end - start_time) > 10:
              iterrun = i + 1
              break
      time_list.sort()
      # remove top and least 10% data
      time_list = time_list[int(0.1 * iterrun) : int(0.9 * iterrun)]
      return np.mean(time_list) * 1000, True
  
imports: import time
  import numpy
  from typing import Sequence
label_desc: Use image node_id 1 for calling a global function with example usage: latency_calculate_helper(iterrun, baseline_time, func) and returns: unknown,  True, unknown,  False