code: def restore_poly(
      instance_yxs_list,
      seq_strs,
      p_border,
      ratio_w,
      ratio_h,
      src_w,
      src_h,
      valid_set,
  ):
      poly_list = []
      keep_str_list = []
      for yx_center_line, keep_str in zip(instance_yxs_list, seq_strs):
          if len(keep_str) < 2:
              print("--> too short, {}".format(keep_str))
              continue
  
          offset_expand = 1.0
          if valid_set == "totaltext":
              offset_expand = 1.2
  
          point_pair_list = []
          for y, x in yx_center_line:
              offset = p_border[:, y, x].reshape(2, 2) * offset_expand
              ori_yx = np.array([y, x], dtype=np.float32)
              point_pair = (
                  (ori_yx + offset)[:, ::-1]
                  * 4.0
                  / np.array([ratio_w, ratio_h]).reshape(-1, 2)
              )
              point_pair_list.append(point_pair)
  
          detected_poly = point_pair2poly(point_pair_list)
          detected_poly = expand_poly_along_width(
              detected_poly, shrink_ratio_of_width=0.2
          )
          detected_poly[:, 0] = np.clip(
              detected_poly[:, 0], a_min=0, a_max=src_w
          )
          detected_poly[:, 1] = np.clip(
              detected_poly[:, 1], a_min=0, a_max=src_h
          )
  
          keep_str_list.append(keep_str)
          if valid_set == "partvgg":
              middle_point = len(detected_poly) // 2
              detected_poly = detected_poly[
                  [0, middle_point - 1, middle_point, -1], :
              ]
              poly_list.append(detected_poly)
          elif valid_set == "totaltext":
              poly_list.append(detected_poly)
          else:
              print("--> Not supported format.")
              exit(-1)
      return poly_list, keep_str_list
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import cv2
  import math
  import numpy
  from itertools import groupby
  from skimage.morphology._skeletonize import thin
label_desc: Use image node_id 16 for calling a global function with example usage: restore_poly(instance_yxs_list, seq_strs, p_border, ratio_w, ratio_h, src_w, src_h, valid_set) and returns: poly_list,  keep_str_list