code: def rotate_img(self, img, angle, canvas_size):
      h, w = img.shape[:2]
      rotation_matrix = cv2.getRotationMatrix2D(
          (w / 2, h / 2), angle, 1
      )
      rotation_matrix[0, 2] += int((canvas_size[1] - w) / 2)
      rotation_matrix[1, 2] += int((canvas_size[0] - h) / 2)
  
      if self.pad_with_fixed_color:
          target_img = cv2.warpAffine(
              img,
              rotation_matrix,
              (canvas_size[1], canvas_size[0]),
              flags=cv2.INTER_NEAREST,
              borderValue=self.pad_value,
          )
      else:
          mask = np.zeros_like(img)
          (h_ind, w_ind) = (
              np.random.randint(0, h * 7 // 8),
              np.random.randint(0, w * 7 // 8),
          )
          img_cut = img[
              h_ind : (h_ind + h // 9), w_ind : (w_ind + w // 9)
          ]
          img_cut = cv2.resize(
              img_cut, (canvas_size[1], canvas_size[0])
          )
  
          mask = cv2.warpAffine(
              mask,
              rotation_matrix,
              (canvas_size[1], canvas_size[0]),
              borderValue=[1, 1, 1],
          )
          target_img = cv2.warpAffine(
              img,
              rotation_matrix,
              (canvas_size[1], canvas_size[0]),
              borderValue=[0, 0, 0],
          )
          target_img = target_img + img_cut * mask
  
      return target_img
  
imports: import numpy
  from PIL import Image, ImageDraw
  import cv2
  from shapely.geometry import Polygon
  import math
  from ppocr.utils.poly_nms import poly_intersection
label_desc: Use image node_id 5 for calling the RandomRotatePolyInstances obj's underlying member method code with example usage: obj.rotate_img(img, angle, canvas_size) and returns: target_img