code: def merge_results_by_nms(
      results: SampleList,
      offsets: Sequence[Tuple[int, int]],
      src_image_shape: Tuple[int, int],
      nms_cfg: dict,
  ) -> DetDataSample:
      """Merge patch results by nms.
  
      Args:
          results (List[:obj:`DetDataSample`]): A list of patch results.
          offsets (Sequence[Tuple[int, int]]): Positions of the left top points
              of patches.
          src_image_shape (Tuple[int, int]): A (height, width) tuple of the large
              image's width and height.
          nms_cfg (dict): it should specify nms type and other parameters
              like `iou_threshold`.
      Returns:
          :obj:`DetDataSample`: merged results.
      """
      shifted_instances = shift_predictions(
          results, offsets, src_image_shape
      )
  
      _, keeps = batched_nms(
          boxes=shifted_instances.bboxes,
          scores=shifted_instances.scores,
          idxs=shifted_instances.labels,
          nms_cfg=nms_cfg,
      )
      merged_instances = shifted_instances[keeps]
  
      merged_result = results[0].clone()
      merged_result.pred_instances = merged_instances
      return merged_result
  
imports: from typing import Sequence, Tuple
  import torch
  from mmcv.ops import batched_nms
  from mmengine.structures import InstanceData
  from mmdet.structures import DetDataSample, SampleList
label_desc: Use image node_id 3 for calling a global function with example usage: merge_results_by_nms(results, offsets, src_image_shape, nms_cfg) and returns: merged_result