code: def selective_search(im_orig, scale=1.0, sigma=0.8, min_size=50):
      """Selective Search
  
      Parameters
      ----------
          im_orig : ndarray
              Input image
          scale : int
              Free parameter. Higher means larger clusters in felzenszwalb segmentation.
          sigma : float
              Width of Gaussian kernel for felzenszwalb segmentation.
          min_size : int
              Minimum component size for felzenszwalb segmentation.
      Returns
      -------
          img : ndarray
              image with region label
              region label is stored in the 4th value of each pixel [r,g,b,(region)]
          regions : array of dict
              [
                  {
                      'rect': (left, top, right, bottom),
                      'labels': [...]
                  },
                  ...
              ]
      """
      assert im_orig.shape[2] == 3, "3ch image is expected"
  
      # load image and get smallest regions
      # region label is stored in the 4th value of each pixel [r,g,b,(region)]
      img = _generate_segments(im_orig, scale, sigma, min_size)
  
      if img is None:
          return None, {}
  
      imsize = img.shape[0] * img.shape[1]
      R = _extract_regions(img)
  
      # extract neighbouring information
      neighbours = list(_extract_neighbours(R))
  
      # calculate initial similarities
      S = {}
      for (ai, ar), (bi, br) in neighbours:
          S[(ai, bi)] = _calc_sim(ar, br, imsize)
  
      # hierarchal search
      while S != {}:
          # get highest similarity
          if sys.version_info[0] < 3:
              i, j = sorted(S.items(), cmp=mycmp)[-1][0]
          else:
              i, j = sorted(S.items(), key=cmp_to_key(mycmp))[-1][0]
  
          # merge corresponding regions
          t = max(R.keys()) + 1.0
          R[t] = _merge_regions(R[i], R[j])
  
          # mark similarities for regions to be removed
          key_to_delete = []
          for k, v in S.items():
              if (i in k) or (j in k):
                  key_to_delete.append(k)
  
          # remove old similarities of related regions
          for k in key_to_delete:
              del S[k]
  
          # calculate similarity set with the new region
          for k in filter(lambda a: a != (i, j), key_to_delete):
              n = k[1] if k[0] in (i, j) else k[0]
              S[(t, n)] = _calc_sim(R[t], R[n], imsize)
  
      regions = []
      for k, r in R.items():
          regions.append(
              {
                  "rect": (
                      r["min_x"],
                      r["min_y"],
                      r["max_x"] - r["min_x"],
                      r["max_y"] - r["min_y"],
                  ),
                  "size": r["size"],
                  "labels": r["labels"],
              }
          )
  
      return img, regions
  
imports: import sys
  from past.builtins import cmp
  import skimage.io
  import skimage.feature
  import skimage.color
  import skimage.transform
  import skimage.util
  import skimage.segmentation
  import numpy
label_desc: Use image node_id 15 for calling a global function with example usage: selective_search(im_orig, scale, sigma, min_size) and returns: img,  regions, None,  dict