code: def get_results(
      cf, img_shape, detections, seg_logits, box_results_list=None
  ):
      """
      Restores batch dimension of merged detections, unmolds detections, creates and fills results dict.
      :param img_shape:
      :param detections: (n_final_detections, (y1, x1, y2, x2, (z1), (z2), batch_ix, pred_class_id, pred_score)
      :param box_results_list: None or list of output boxes for monitoring/plotting.
      each element is a list of boxes per batch element.
      :return: results_dict: dictionary with keys:
               'boxes': list over batch elements. each batch element is a list of boxes. each box is a dictionary:
                        [[{box_0}, ... {box_n}], [{box_0}, ... {box_n}], ...]
               'seg_preds': pixel-wise class predictions (b, 1, y, x, (z)) with values [0, ..., n_classes] for
                            retina_unet and dummy array for retina_net.
      """
      detections = detections.cpu().data.numpy()
      batch_ixs = detections[:, cf.dim * 2]
      detections = [
          detections[batch_ixs == ix] for ix in range(img_shape[0])
      ]
  
      # for test_forward, where no previous list exists.
      if box_results_list is None:
          box_results_list = [[] for _ in range(img_shape[0])]
  
      for ix in range(img_shape[0]):
          if 0 not in detections[ix].shape:
              boxes = detections[ix][:, : 2 * cf.dim].astype(np.int32)
              class_ids = detections[ix][:, 2 * cf.dim + 1].astype(
                  np.int32
              )
              scores = detections[ix][:, 2 * cf.dim + 2]
  
              # Filter out detections with zero area. Often only happens in early
              # stages of training when the network weights are still a bit random.
              if cf.dim == 2:
                  exclude_ix = np.where(
                      (boxes[:, 2] - boxes[:, 0])
                      * (boxes[:, 3] - boxes[:, 1])
                      <= 0
                  )[0]
              else:
                  exclude_ix = np.where(
                      (boxes[:, 2] - boxes[:, 0])
                      * (boxes[:, 3] - boxes[:, 1])
                      * (boxes[:, 5] - boxes[:, 4])
                      <= 0
                  )[0]
  
              if exclude_ix.shape[0] > 0:
                  boxes = np.delete(boxes, exclude_ix, axis=0)
                  class_ids = np.delete(class_ids, exclude_ix, axis=0)
                  scores = np.delete(scores, exclude_ix, axis=0)
  
              if 0 not in boxes.shape:
                  for ix2, score in enumerate(scores):
                      if score >= cf.model_min_confidence:
                          box_results_list[ix].append(
                              {
                                  "box_coords": boxes[ix2],
                                  "box_score": score,
                                  "box_type": "det",
                                  "box_pred_class_id": class_ids[ix2],
                              }
                          )
  
      results_dict = {"boxes": box_results_list}
      if seg_logits is None:
          # output dummy segmentation for retina_net.
          results_dict["seg_preds"] = np.zeros(img_shape)[:, 0][
              :, np.newaxis
          ]
      else:
          # output label maps for retina_unet.
          results_dict["seg_preds"] = (
              F.softmax(seg_logits, 1)
              .argmax(1)
              .cpu()
              .data.numpy()[:, np.newaxis]
              .astype("uint8")
          )
  
      return results_dict
  
imports: import utils.model_utils
  import utils.exp_utils
  import sys
  from cuda_functions.nms_2D.pth_nms import nms_gpu
  from cuda_functions.nms_3D.pth_nms import nms_gpu
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils
label_desc: Use image node_id 4 for calling a global function with example usage: get_results(cf, img_shape, detections, seg_logits, box_results_list) and returns: results_dict