code: def gen_mask(query_ids, reg_ids):
      mask = []
      for query_id in query_ids:
          pos = [i for i, x in enumerate(reg_ids) if query_id == x]
          if len(pos) != 1:
              raise RuntimeError(
                  "RegIdsError with id = {}， duplicate = {} ".format(
                      query_id, len(pos)
                  )
              )
          mask.append(pos[0])
      return mask
  
imports: import os
  import numpy
  import timeit
  import sklearn
  import cv2
  import sys
  import argparse
  import glob
  import numpy.matlib
  import heapq
  import math
  from datetime import datetime
  from sklearn import preprocessing
  from embedding import Embedding
  from menpo.visualize import print_progress
  from menpo.visualize.viewmatplotlib import sample_colours_from_colourmap
label_desc: Use image node_id 9 for calling a global function with example usage: gen_mask(query_ids, reg_ids) and returns: mask