code: def param2stroke(param, H, W, meta_brushes):
      """
      param2stroke
      """
      b = param.shape[0]
      param_list = paddle.split(param, 8, axis=1)
      x0, y0, w, h, theta = [
          item.squeeze(-1) for item in param_list[:5]
      ]
      sin_theta = paddle.sin(math.pi * theta)
      cos_theta = paddle.cos(math.pi * theta)
      index = paddle.full((b,), -1, dtype="int64").numpy()
  
      index[(h > w).numpy()] = 0
      index[(h <= w).numpy()] = 1
      meta_brushes_resize = F.interpolate(meta_brushes, (H, W)).numpy()
      brush = paddle.to_tensor(meta_brushes_resize[index])
  
      warp_00 = cos_theta / w
      warp_01 = sin_theta * H / (W * w)
      warp_02 = (1 - 2 * x0) * cos_theta / w + (
          1 - 2 * y0
      ) * sin_theta * H / (W * w)
      warp_10 = -sin_theta * W / (H * h)
      warp_11 = cos_theta / h
      warp_12 = (1 - 2 * y0) * cos_theta / h - (
          1 - 2 * x0
      ) * sin_theta * W / (H * h)
      warp_0 = paddle.stack([warp_00, warp_01, warp_02], axis=1)
      warp_1 = paddle.stack([warp_10, warp_11, warp_12], axis=1)
      warp = paddle.stack([warp_0, warp_1], axis=1)
      grid = nn.functional.affine_grid(
          warp, [b, 3, H, W]
      )  # paddle和torch默认值是反过来的
      brush = nn.functional.grid_sample(brush, grid)
      return brush
  
file_path: PaddleHub/modules/image/Image_gan/style_transfer/paint_transformer/render_utils.py
imports: import paddle
  import paddle.nn
  import paddle.nn.functional
  import cv2
  import numpy
  from PIL import Image
  import math
label_desc: Use image node_id 1 for calling a global function with example usage: param2stroke(param, H, W, meta_brushes) and returns: brush