docstr: Generate local graphs as GCN input.
  
  Args:
      feat_maps (Tensor): The feature maps to extract the content
          features of text components.
      comp_attribs (ndarray): The text component attributes.
  
  Returns:
      local_graphs_node_feat (Tensor): The node features of graph.
      adjacent_matrices (Tensor): The adjacent matrices of local graphs.
      pivots_knn_inds (Tensor): The k-nearest neighbor indices in local
          graph.
      gt_linkage (Tensor): The surpervision signal of GCN for linkage
          prediction.
docstr_tok: ["Generate","local","graphs","as","GCN","input",".","Args",":","feat_maps","(","Tensor",")",":","The","feature","maps","to","extract","the","content","features","of","text","components",".","comp_attribs","(","ndarray",")",":","The","text","component","attributes",".","Returns",":","local_graphs_node_feat","(","Tensor",")",":","The","node","features","of","graph",".","adjacent_matrices","(","Tensor",")",":","The","adjacent","matrices","of","local","graphs",".","pivots_knn_inds","(","Tensor",")",":","The","k-nearest","neighbor","indices","in","local","graph",".","gt_linkage","(","Tensor",")",":","The","surpervision","signal","of","GCN","for","linkage","prediction","."]
code: def __call__(self, feat_maps, comp_attribs):
      """Generate local graphs as GCN input.
  
      Args:
          feat_maps (Tensor): The feature maps to extract the content
              features of text components.
          comp_attribs (ndarray): The text component attributes.
  
      Returns:
          local_graphs_node_feat (Tensor): The node features of graph.
          adjacent_matrices (Tensor): The adjacent matrices of local graphs.
          pivots_knn_inds (Tensor): The k-nearest neighbor indices in local
              graph.
          gt_linkage (Tensor): The surpervision signal of GCN for linkage
              prediction.
      """
  
      assert isinstance(feat_maps, paddle.Tensor)
      assert comp_attribs.ndim == 3
      assert comp_attribs.shape[2] == 8
  
      sorted_dist_inds_batch = []
      local_graph_batch = []
      knn_batch = []
      node_feat_batch = []
      node_label_batch = []
  
      for batch_ind in range(comp_attribs.shape[0]):
          num_comps = int(comp_attribs[batch_ind, 0, 0])
          comp_geo_attribs = comp_attribs[batch_ind, :num_comps, 1:7]
          node_labels = comp_attribs[batch_ind, :num_comps, 7].astype(
              np.int32
          )
  
          comp_centers = comp_geo_attribs[:, 0:2]
          distance_matrix = euclidean_distance_matrix(
              comp_centers, comp_centers
          )
  
          batch_id = (
              np.zeros((comp_geo_attribs.shape[0], 1), dtype=np.float32)
              * batch_ind
          )
          comp_geo_attribs[:, -2] = np.clip(
              comp_geo_attribs[:, -2], -1, 1
          )
          angle = np.arccos(comp_geo_attribs[:, -2]) * np.sign(
              comp_geo_attribs[:, -1]
          )
          angle = angle.reshape((-1, 1))
          rotated_rois = np.hstack(
              [batch_id, comp_geo_attribs[:, :-2], angle]
          )
          rois = paddle.to_tensor(rotated_rois)
          content_feats = self.pooling(
              feat_maps[batch_ind].unsqueeze(0), rois
          )
  
          content_feats = content_feats.reshape(
              [content_feats.shape[0], -1]
          )
          geo_feats = feature_embedding(
              comp_geo_attribs, self.node_geo_feat_dim
          )
          geo_feats = paddle.to_tensor(geo_feats)
          node_feats = paddle.concat(
              [content_feats, geo_feats], axis=-1
          )
  
          sorted_dist_inds = np.argsort(distance_matrix, axis=1)
          pivot_local_graphs, pivot_knns = self.generate_local_graphs(
              sorted_dist_inds, node_labels
          )
  
          node_feat_batch.append(node_feats)
          node_label_batch.append(node_labels)
          local_graph_batch.append(pivot_local_graphs)
          knn_batch.append(pivot_knns)
          sorted_dist_inds_batch.append(sorted_dist_inds)
  
      (
          node_feats,
          adjacent_matrices,
          knn_inds,
          gt_linkage,
      ) = self.generate_gcn_input(
          node_feat_batch,
          node_label_batch,
          local_graph_batch,
          knn_batch,
          sorted_dist_inds_batch,
      )
  
      return node_feats, adjacent_matrices, knn_inds, gt_linkage
  
file_path: PaddleOCR/ppocr/modeling/heads/local_graph.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import paddle
  import paddle.nn
  from ppocr.ext_op import RoIAlignRotated
label_desc: Use image node_id 4 for calling the LocalGraphs obj's underlying member method code with example usage: obj.__call__(feat_maps, comp_attribs) and returns: node_feats,  adjacent_matrices,  knn_inds,  gt_linkage