code: def merge(img_ids, eval_imgs):
      all_img_ids = all_gather(img_ids)
      all_eval_imgs = all_gather(eval_imgs)
  
      merged_img_ids = []
      for p in all_img_ids:
          merged_img_ids.extend(p)
  
      merged_eval_imgs = []
      for p in all_eval_imgs:
          merged_eval_imgs.append(p)
  
      merged_img_ids = np.array(merged_img_ids)
      merged_eval_imgs = np.concatenate(merged_eval_imgs, 2)
  
      # keep only unique (and in sorted order) images
      merged_img_ids, idx = np.unique(merged_img_ids, return_index=True)
      merged_eval_imgs = merged_eval_imgs[..., idx]
  
      return merged_img_ids, merged_eval_imgs
  
imports: import json
  import copy
  from collections import defaultdict
  import numpy
  import torch
  import torch._six
  from pycocotools.cocoeval import COCOeval
  from pycocotools.coco import COCO
  import pycocotools.mask
  from train_utils.distributed_utils import all_gather
label_desc: Use image node_id 2 for calling a global function with example usage: merge(img_ids, eval_imgs) and returns: merged_img_ids,  merged_eval_imgs