code: def set_result_with_confidence(results):
      """Select highest confidence augmentation for TTA
      Given a list of lists of results (outer list has one list per augmentation,
      inner lists index the images being recognized), choose the best result
      according to confidence level.
      Each "result" is of the form (box coords, text, confidence)
      A final_result is returned which contains one result for each image
      """
      final_result = []
      for col_ix in range(len(results[0])):
          # Take the row_ix associated with the max confidence
          best_row = max(
              [
                  (row_ix, results[row_ix][col_ix][2])
                  for row_ix in range(len(results))
              ],
              key=lambda x: x[1],
          )[0]
          final_result.append(results[best_row][col_ix])
  
      return final_result
  
imports: from __future__ import print_function
  import torch
  import pickle
  import numpy
  import math
  import cv2
  from PIL import Image, JpegImagePlugin
  from scipy import ndimage
  import hashlib
  import sys, os
  from zipfile import ZipFile
  from .imgproc import loadImage
label_desc: Use image node_id 22 for calling a global function with example usage: set_result_with_confidence(results) and returns: final_result