code: def get_affine_transform(
      center, scale, rot, output_size, inverse=False
  ):
      """Affine transform."""
      if not isinstance(scale, (np.ndarray, list)):
          scale = np.array([scale, scale], dtype=np.float32)
  
      dst_w, dst_h = output_size[0], output_size[1]
  
      rot_rad = np.pi * rot / 180
      src_dir = get_dir([0, scale[0] * -0.5], rot_rad)
      dst_dir = np.array([0, dst_w * -0.5], np.float32)
  
      src = np.zeros((3, 2), dtype=np.float32)
      dst = np.zeros((3, 2), dtype=np.float32)
      src[0, :], src[1, :] = center, center + src_dir
      dst[0, :] = [dst_w * 0.5, dst_h * 0.5]
      dst[1, :] = (
          np.array([dst_w * 0.5, dst_h * 0.5], np.float32) + dst_dir
      )
  
      src[2:, :] = get_3rd_point(src[0, :], src[1, :])
      dst[2:, :] = get_3rd_point(dst[0, :], dst[1, :])
  
      if inverse:
          transform = cv2.getAffineTransform(
              np.float32(dst), np.float32(src)
          )
      else:
          transform = cv2.getAffineTransform(
              np.float32(src), np.float32(dst)
          )
  
      return transform
  
imports: import cv2
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: get_affine_transform(center, scale, rot, output_size, inverse) and returns: transform