docstr: check so that the text poly is in the same direction,
  and also filter some invalid polygons
  :param polys:
  :param tags:
  :return:
docstr_tok: ["check","so","that","the","text","poly","is","in","the","same","direction",",","and","also","filter","some","invalid","polygons",":","param","polys",":",":","param","tags",":",":","return",":"]
code: def check_and_validate_polys(self, polys, tags, im_size):
      """
      check so that the text poly is in the same direction,
      and also filter some invalid polygons
      :param polys:
      :param tags:
      :return:
      """
      (h, w) = im_size
      if polys.shape[0] == 0:
          return polys, np.array([]), np.array([])
      polys[:, :, 0] = np.clip(polys[:, :, 0], 0, w - 1)
      polys[:, :, 1] = np.clip(polys[:, :, 1], 0, h - 1)
  
      validated_polys = []
      validated_tags = []
      hv_tags = []
      for poly, tag in zip(polys, tags):
          quad = self.gen_quad_from_poly(poly)
          p_area = self.quad_area(quad)
          if abs(p_area) < 1:
              print("invalid poly")
              continue
          if p_area > 0:
              if tag == False:
                  print("poly in wrong direction")
                  tag = True  # reversed cases should be ignore
              poly = poly[
                  (
                      0,
                      15,
                      14,
                      13,
                      12,
                      11,
                      10,
                      9,
                      8,
                      7,
                      6,
                      5,
                      4,
                      3,
                      2,
                      1,
                  ),
                  :,
              ]
              quad = quad[(0, 3, 2, 1), :]
  
          len_w = np.linalg.norm(quad[0] - quad[1]) + np.linalg.norm(
              quad[3] - quad[2]
          )
          len_h = np.linalg.norm(quad[0] - quad[3]) + np.linalg.norm(
              quad[1] - quad[2]
          )
          hv_tag = 1
  
          if len_w * 2.0 < len_h:
              hv_tag = 0
  
          validated_polys.append(poly)
          validated_tags.append(tag)
          hv_tags.append(hv_tag)
      return (
          np.array(validated_polys),
          np.array(validated_tags),
          np.array(hv_tags),
      )
  
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 5 for calling the PGProcessTrain obj's underlying member method code with example usage: obj.check_and_validate_polys(polys, tags, im_size) and returns: np,  np,  np, polys,  np,  np