code: def get_single_layer_lists(
      param,
      decision,
      ori_img,
      render_size_x,
      render_size_y,
      h,
      w,
      meta_brushes,
      dilation,
      erosion,
      stroke_num,
  ):
      """
      get_single_layer_lists
      """
      valid_foregrounds = param2stroke(
          param[:, :], render_size_y, render_size_x, meta_brushes
      )
  
      valid_alphas = (valid_foregrounds > 0).astype("float32")
      valid_foregrounds = valid_foregrounds.reshape(
          [-1, stroke_num, 1, render_size_y, render_size_x]
      )
      valid_alphas = valid_alphas.reshape(
          [-1, stroke_num, 1, render_size_y, render_size_x]
      )
  
      temp = [
          dilation(valid_foregrounds[:, i, :, :, :])
          for i in range(stroke_num)
      ]
      valid_foregrounds = paddle.stack(temp, axis=1)
      valid_foregrounds = valid_foregrounds.reshape(
          [-1, 1, render_size_y, render_size_x]
      )
  
      temp = [
          erosion(valid_alphas[:, i, :, :, :])
          for i in range(stroke_num)
      ]
      valid_alphas = paddle.stack(temp, axis=1)
      valid_alphas = valid_alphas.reshape(
          [-1, 1, render_size_y, render_size_x]
      )
  
      patch_y = 4 * render_size_y // 5
      patch_x = 4 * render_size_x // 5
  
      img_patch = ori_img.reshape(
          [1, 3, h, ori_img.shape[2] // h, w, ori_img.shape[3] // w]
      )
      img_patch = img_patch.transpose([0, 2, 4, 1, 3, 5])[0]
  
      xid_list = []
      yid_list = []
      error_list = []
  
      for flag_idx, flag in enumerate(decision.cpu().numpy()):
          if flag:
              flag_idx = flag_idx // stroke_num
              x_id = flag_idx % w
              flag_idx = flag_idx // w
              y_id = flag_idx % h
              xid_list.append(x_id)
              yid_list.append(y_id)
  
      inner_fores = valid_foregrounds[
          :,
          :,
          render_size_y // 10 : 9 * render_size_y // 10,
          render_size_x // 10 : 9 * render_size_x // 10,
      ]
      inner_alpha = valid_alphas[
          :,
          :,
          render_size_y // 10 : 9 * render_size_y // 10,
          render_size_x // 10 : 9 * render_size_x // 10,
      ]
      inner_fores = inner_fores.reshape(
          [h * w, stroke_num, 1, patch_y, patch_x]
      )
      inner_alpha = inner_alpha.reshape(
          [h * w, stroke_num, 1, patch_y, patch_x]
      )
      inner_real = img_patch.reshape(
          [h * w, 3, patch_y, patch_x]
      ).unsqueeze(1)
  
      R = param[:, 5]
      G = param[:, 6]
      B = param[:, 7]  # , G, B = param[5:]
      R = (
          R.reshape([-1, stroke_num])
          .unsqueeze(-1)
          .unsqueeze(-1)
          .unsqueeze(-1)
      )
      G = (
          G.reshape([-1, stroke_num])
          .unsqueeze(-1)
          .unsqueeze(-1)
          .unsqueeze(-1)
      )
      B = (
          B.reshape([-1, stroke_num])
          .unsqueeze(-1)
          .unsqueeze(-1)
          .unsqueeze(-1)
      )
      error_R = R * inner_fores - inner_real[:, :, 0:1, :, :]
      error_G = G * inner_fores - inner_real[:, :, 1:2, :, :]
      error_B = B * inner_fores - inner_real[:, :, 2:3, :, :]
      error = (
          paddle.abs(error_R)
          + paddle.abs(error_G)
          + paddle.abs(error_B)
      )
  
      error = error * inner_alpha
      error = paddle.sum(error, axis=(2, 3, 4)) / paddle.sum(
          inner_alpha, axis=(2, 3, 4)
      )
      error_list = error.reshape([-1]).numpy()[decision.numpy()]
      error_list = list(error_list)
  
      valid_foregrounds = paddle.to_tensor(
          valid_foregrounds.numpy()[decision.numpy()]
      )
      valid_alphas = paddle.to_tensor(
          valid_alphas.numpy()[decision.numpy()]
      )
  
      selected_param = paddle.to_tensor(param.numpy()[decision.numpy()])
      return (
          xid_list,
          yid_list,
          valid_foregrounds,
          valid_alphas,
          error_list,
          selected_param,
      )
  
file_path: PaddleHub/modules/image/Image_gan/style_transfer/paint_transformer/render_serial.py
imports: import paddle
  import paddle.nn
  import paddle.nn.functional
  import numpy
  from PIL import Image
  import math
  import cv2
  import time
  from .render_utils import param2stroke, Dilation2d, Erosion2d
label_desc: Use image node_id 1 for calling a global function with example usage: get_single_layer_lists(param, decision, ori_img, render_size_x, render_size_y, h, w, meta_brushes, dilation, erosion, stroke_num) and returns: xid_list,  yid_list,  valid_foregrounds,  valid_alphas,  error_list,  selected_param