code: def search_similar(
      inputs,
      compare_to,
      algorithm="euclidean",
      topk=5,
      invert_score=True,
  ):
      all_scores = scipy.spatial.distance.cdist(
          inputs, compare_to, algorithm
      )
      all_results = []
      for input_val, scores in zip(inputs, all_scores):
          result = []
          for i, (score, data) in enumerate(zip(scores, compare_to)):
              if invert_score:
                  score = 1 / (score + 1.0e-6)
              if len(result) < topk:
                  heapq.heappush(result, (score, (i, input_val, data)))
              else:
                  heapq.heappushpop(
                      result, (score, (i, input_val, data))
                  )
          all_results.append(result)
      return all_results
  
file_path: tensorwatch/tensorwatch/data_utils.py
imports: import random
  import scipy.spatial.distance
  import heapq
  import numpy
  import torch
label_desc: Use image node_id 6 for calling a global function with example usage: search_similar(inputs, compare_to, algorithm, topk, invert_score) and returns: all_results