docstr: shrink poly with given length.
docstr_tok: ["shrink","poly","with","given","length","."]
code: def shrink_poly_along_width(
      self, quads, shrink_ratio_of_width, expand_height_ratio=1.0
  ):
      """
      shrink poly with given length.
      """
      upper_edge_list = []
  
      def get_cut_info(edge_len_list, cut_len):
          for idx, edge_len in enumerate(edge_len_list):
              cut_len -= edge_len
              if cut_len <= 0.000001:
                  ratio = (
                      cut_len + edge_len_list[idx]
                  ) / edge_len_list[idx]
                  return idx, ratio
  
      for quad in quads:
          upper_edge_len = np.linalg.norm(quad[0] - quad[1])
          upper_edge_list.append(upper_edge_len)
  
      # length of left edge and right edge.
      left_length = (
          np.linalg.norm(quads[0][0] - quads[0][3])
          * expand_height_ratio
      )
      right_length = (
          np.linalg.norm(quads[-1][1] - quads[-1][2])
          * expand_height_ratio
      )
  
      shrink_length = (
          min(left_length, right_length, sum(upper_edge_list))
          * shrink_ratio_of_width
      )
      # shrinking length
      upper_len_left = shrink_length
      upper_len_right = sum(upper_edge_list) - shrink_length
  
      left_idx, left_ratio = get_cut_info(
          upper_edge_list, upper_len_left
      )
      left_quad = self.shrink_quad_along_width(
          quads[left_idx],
          begin_width_ratio=left_ratio,
          end_width_ratio=1,
      )
      right_idx, right_ratio = get_cut_info(
          upper_edge_list, upper_len_right
      )
      right_quad = self.shrink_quad_along_width(
          quads[right_idx],
          begin_width_ratio=0,
          end_width_ratio=right_ratio,
      )
  
      out_quad_list = []
      if left_idx == right_idx:
          out_quad_list.append(
              [left_quad[0], right_quad[1], right_quad[2], left_quad[3]]
          )
      else:
          out_quad_list.append(left_quad)
          for idx in range(left_idx + 1, right_idx):
              out_quad_list.append(quads[idx])
          out_quad_list.append(right_quad)
  
      return np.array(out_quad_list), list(
          range(left_idx, right_idx + 1)
      )
  
imports: import math
  import cv2
  import numpy
  from skimage.morphology._skeletonize import thin
  from ppocr.utils.e2e_utils.extract_textpoint_fast import sort_and_expand_with_direction_v2
label_desc: Use image node_id 15 for calling the PGProcessTrain obj's underlying member method code with example usage: obj.shrink_poly_along_width(quads, shrink_ratio_of_width, expand_height_ratio) and returns: np,  list, idx,  ratio