docstr_tok: []
code: def generate_direction_map(self, poly_quads, direction_map):
      """ """
      width_list = []
      height_list = []
      for quad in poly_quads:
          quad_w = (
              np.linalg.norm(quad[0] - quad[1])
              + np.linalg.norm(quad[2] - quad[3])
          ) / 2.0
          quad_h = (
              np.linalg.norm(quad[0] - quad[3])
              + np.linalg.norm(quad[2] - quad[1])
          ) / 2.0
          width_list.append(quad_w)
          height_list.append(quad_h)
      norm_width = max(sum(width_list) / (len(width_list) + 1e-6), 1.0)
      average_height = max(
          sum(height_list) / (len(height_list) + 1e-6), 1.0
      )
  
      for quad in poly_quads:
          direct_vector_full = (
              (quad[1] + quad[2]) - (quad[0] + quad[3])
          ) / 2.0
          direct_vector = (
              direct_vector_full
              / (np.linalg.norm(direct_vector_full) + 1e-6)
              * norm_width
          )
          direction_label = tuple(
              map(
                  float,
                  [
                      direct_vector[0],
                      direct_vector[1],
                      1.0 / (average_height + 1e-6),
                  ],
              )
          )
          cv2.fillPoly(
              direction_map,
              quad.round().astype(np.int32)[np.newaxis, :, :],
              direction_label,
          )
      return direction_map
  
imports: import math
  import cv2
  import numpy
  import json
  import sys
  import os
label_desc: Use image node_id 6 for calling the SASTProcessTrain obj's underlying member method code with example usage: obj.generate_direction_map(poly_quads, direction_map) and returns: direction_map