code: def shift_predictions(
      det_data_samples: SampleList,
      offsets: Sequence[Tuple[int, int]],
      src_image_shape: Tuple[int, int],
  ) -> SampleList:
      """Shift predictions to the original image.
  
      Args:
          det_data_samples (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.
      Returns:
          (List[:obj:`DetDataSample`]): shifted results.
      """
      try:
          from sahi.slicing import shift_bboxes, shift_masks
      except ImportError:
          raise ImportError(
              'Please run "pip install -U sahi" '
              "to install sahi first for large image inference."
          )
  
      assert len(det_data_samples) == len(offsets), (
          "The `results` should has the " "same length with `offsets`."
      )
      shifted_predictions = []
      for det_data_sample, offset in zip(det_data_samples, offsets):
          pred_inst = det_data_sample.pred_instances.clone()
  
          # Check bbox type
          if pred_inst.bboxes.size(-1) == 4:
              # Horizontal bboxes
              shifted_bboxes = shift_bboxes(pred_inst.bboxes, offset)
          elif pred_inst.bboxes.size(-1) == 5:
              # Rotated bboxes
              shifted_bboxes = shift_rbboxes(pred_inst.bboxes, offset)
          else:
              raise NotImplementedError
  
          # shift bboxes and masks
          pred_inst.bboxes = shifted_bboxes
          if "masks" in det_data_sample:
              pred_inst.masks = shift_masks(
                  pred_inst.masks, offset, src_image_shape
              )
  
          shifted_predictions.append(pred_inst.clone())
  
      shifted_predictions = InstanceData.cat(shifted_predictions)
  
      return shifted_predictions
  
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 2 for calling a global function with example usage: shift_predictions(det_data_samples, offsets, src_image_shape) and returns: shifted_predictions