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, xxx_todo_changeme):
      """
      check so that the text poly is in the same direction,
      and also filter some invalid polygons
      :param polys:
      :param tags:
      :return:
      """
      (h, w) = xxx_todo_changeme
      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
  import json
  import sys
  import os
label_desc: Use image node_id 4 for calling the SASTProcessTrain obj's underlying member method code with example usage: obj.check_and_validate_polys(polys, tags, xxx_todo_changeme) and returns: np,  np,  np, polys,  np,  np