docstr: Generate tbo_map for give quad.
docstr_tok: ["Generate","tbo_map","for","give","quad","."]
code: def gen_quad_tbo(self, quad, tcl_mask, tbo_map):
      """
      Generate tbo_map for give quad.
      """
      # upper and lower line function: ax + by + c = 0;
      up_line = self.line_cross_two_point(quad[0], quad[1])
      lower_line = self.line_cross_two_point(quad[3], quad[2])
  
      quad_h = 0.5 * (
          np.linalg.norm(quad[0] - quad[3])
          + np.linalg.norm(quad[1] - quad[2])
      )
      quad_w = 0.5 * (
          np.linalg.norm(quad[0] - quad[1])
          + np.linalg.norm(quad[2] - quad[3])
      )
  
      # average angle of left and right line.
      angle = self.average_angle(quad)
  
      xy_in_poly = np.argwhere(tcl_mask == 1)
      for y, x in xy_in_poly:
          point = (x, y)
          line = self.theta_line_cross_point(angle, point)
          cross_point_upper = self.line_cross_point(up_line, line)
          cross_point_lower = self.line_cross_point(lower_line, line)
          ##FIX, offset reverse
          upper_offset_x, upper_offset_y = cross_point_upper - point
          lower_offset_x, lower_offset_y = cross_point_lower - point
          tbo_map[y, x, 0] = upper_offset_y
          tbo_map[y, x, 1] = upper_offset_x
          tbo_map[y, x, 2] = lower_offset_y
          tbo_map[y, x, 3] = lower_offset_x
          tbo_map[y, x, 4] = 1.0 / max(min(quad_h, quad_w), 1.0) * 2
      return tbo_map
  
imports: import math
  import cv2
  import numpy
  import json
  import sys
  import os
label_desc: Use image node_id 21 for calling the SASTProcessTrain obj's underlying member method code with example usage: obj.gen_quad_tbo(quad, tcl_mask, tbo_map) and returns: tbo_map