code: def stroke_net_predict(
      img_patch, result_patch, patch_size, net_g, stroke_num, patch_num
  ):
      """
      stroke_net_predict
      """
      img_patch = img_patch.transpose([0, 2, 1]).reshape(
          [-1, 3, patch_size, patch_size]
      )
      result_patch = result_patch.transpose([0, 2, 1]).reshape(
          [-1, 3, patch_size, patch_size]
      )
      # *----- Stroke Predictor -----*#
      shape_param, stroke_decision = net_g(img_patch, result_patch)
      stroke_decision = (stroke_decision > 0).astype("float32")
      # *----- sampling color -----*#
      grid = shape_param[:, :, :2].reshape(
          [img_patch.shape[0] * stroke_num, 1, 1, 2]
      )
      img_temp = (
          img_patch.unsqueeze(1)
          .tile([1, stroke_num, 1, 1, 1])
          .reshape(
              [
                  img_patch.shape[0] * stroke_num,
                  3,
                  patch_size,
                  patch_size,
              ]
          )
      )
      color = nn.functional.grid_sample(
          img_temp, 2 * grid - 1, align_corners=False
      ).reshape([img_patch.shape[0], stroke_num, 3])
      param = paddle.concat([shape_param, color], axis=-1)
  
      param = param.reshape([-1, 8])
      param[:, :2] = param[:, :2] / 2 + 0.25
      param[:, 2:4] = param[:, 2:4] / 2
      param = param.reshape([1, patch_num, patch_num, stroke_num, 8])
      decision = stroke_decision.reshape(
          [1, patch_num, patch_num, stroke_num]
      )  # .astype('bool')
      return param, decision
  
file_path: PaddleHub/modules/image/Image_gan/style_transfer/paint_transformer/render_parallel.py
imports: import render_utils
  import paddle
  import paddle.nn
  import paddle.nn.functional
  import numpy
  import math
label_desc: Use image node_id 2 for calling a global function with example usage: stroke_net_predict(img_patch, result_patch, patch_size, net_g, stroke_num, patch_num) and returns: param,  decision