class_docstr: The MMOCR Text Detection Local Visualizer.
  
  Args:
      name (str): Name of the instance. Defaults to 'visualizer'.
      image (np.ndarray, optional): the origin image to draw. The format
          should be RGB. Defaults to None.
      vis_backends (list, optional): Visual backend config list.
          Default to None.
      save_dir (str, optional): Save file dir for all storage backends.
          If it is None, the backend storage will not save any data.
      fig_save_cfg (dict): Keyword parameters of figure for saving.
          Defaults to empty dict.
      fig_show_cfg (dict): Keyword parameters of figure for showing.
          Defaults to empty dict.
      is_openset (bool, optional): Whether the visualizer is used in
          OpenSet. Defaults to False.
class_docstr_tok: ["The","MMOCR","Text","Detection","Local","Visualizer",".","Args",":","name","(","str",")",":","Name","of","the","instance",".","Defaults","to","'visualizer","'",".","image","(","np.ndarray",",","optional",")",":","the","origin","image","to","draw",".","The","format","should","be","RGB",".","Defaults","to","None",".","vis_backends","(","list",",","optional",")",":","Visual","backend","config","list",".","Default","to","None",".","save_dir","(","str",",","optional",")",":","Save","file","dir","for","all","storage","backends",".","If","it","is","None",",","the","backend","storage","will","not","save","any","data",".","fig_save_cfg","(","dict",")",":","Keyword","parameters","of","figure","for","saving",".","Defaults","to","empty","dict",".","fig_show_cfg","(","dict",")",":","Keyword","parameters","of","figure","for","showing",".","Defaults","to","empty","dict",".","is_openset","(","bool",",","optional",")",":","Whether","the","visualizer","is","used","in","OpenSet",".","Defaults","to","False","."]
docstr: Draw edge labels on image.
  
  Args:
      image (np.ndarray): The origin image to draw. The format
          should be RGB.
      edge_labels (np.ndarray or torch.Tensor): The edge labels to draw.
          The shape of edge_labels should be (N, N), where N is the
          number of texts.
      bboxes (np.ndarray or torch.Tensor): The bboxes to draw. The shape
          of bboxes should be (N, 4), where N is the number of texts.
      texts (Sequence[str]): The texts to draw. The length of texts
          should be the same as the number of bboxes.
      arrow_colors (str, optional): The colors of arrows. Refer to
          `matplotlib.colors` for full list of formats that are accepted.
          Defaults to 'g'.
  
  Returns:
      np.ndarray: The image with edge labels drawn.
docstr_tok: ["Draw","edge","labels","on","image",".","Args",":","image","(","np.ndarray",")",":","The","origin","image","to","draw",".","The","format","should","be","RGB",".","edge_labels","(","np.ndarray","or","torch.Tensor",")",":","The","edge","labels","to","draw",".","The","shape","of","edge_labels","should","be","(","N",",","N",")",",","where","N","is","the","number","of","texts",".","bboxes","(","np.ndarray","or","torch.Tensor",")",":","The","bboxes","to","draw",".","The","shape","of","bboxes","should","be","(","N",",","4",")",",","where","N","is","the","number","of","texts",".","texts","(","Sequence","[","str","]",")",":","The","texts","to","draw",".","The","length","of","texts","should","be","the","same","as","the","number","of","bboxes",".","arrow_colors","(","str",",","optional",")",":","The","colors","of","arrows",".","Refer","to","`","matplotlib.colors","`","for","full","list","of","formats","that","are","accepted",".","Defaults","to","'","g","'",".","Returns",":","np.ndarray",":","The","image","with","edge","labels","drawn","."]
code: def _draw_edge_label(
      self,
      image: np.ndarray,
      edge_labels: Union[np.ndarray, torch.Tensor],
      bboxes: Union[np.ndarray, torch.Tensor],
      texts: Sequence[str],
      arrow_colors: str = "g",
  ) -> np.ndarray:
      """Draw edge labels on image.
  
      Args:
          image (np.ndarray): The origin image to draw. The format
              should be RGB.
          edge_labels (np.ndarray or torch.Tensor): The edge labels to draw.
              The shape of edge_labels should be (N, N), where N is the
              number of texts.
          bboxes (np.ndarray or torch.Tensor): The bboxes to draw. The shape
              of bboxes should be (N, 4), where N is the number of texts.
          texts (Sequence[str]): The texts to draw. The length of texts
              should be the same as the number of bboxes.
          arrow_colors (str, optional): The colors of arrows. Refer to
              `matplotlib.colors` for full list of formats that are accepted.
              Defaults to 'g'.
  
      Returns:
          np.ndarray: The image with edge labels drawn.
      """
      pairs = np.where(edge_labels > 0)
      if torch.is_tensor(pairs):
          pairs = pairs.cpu()
      key_bboxes = bboxes[pairs[0]]
      value_bboxes = bboxes[pairs[1]]
      x_data = np.stack(
          [
              (key_bboxes[:, 2] + key_bboxes[:, 0]) / 2,
              (value_bboxes[:, 0] + value_bboxes[:, 2]) / 2,
          ],
          axis=-1,
      )
      y_data = np.stack(
          [
              (key_bboxes[:, 1] + key_bboxes[:, 3]) / 2,
              (value_bboxes[:, 1] + value_bboxes[:, 3]) / 2,
          ],
          axis=-1,
      )
      key_index = np.array(list(set(pairs[0])))
      val_index = np.array(list(set(pairs[1])))
      key_texts = [texts[i] for i in key_index]
      val_texts = [texts[i] for i in val_index]
  
      self.set_image(image)
      if key_texts:
          self.draw_texts(
              key_texts,
              (bboxes[key_index, :2] + bboxes[key_index, 2:]) / 2,
              colors="k",
              horizontal_alignments="center",
              vertical_alignments="center",
              font_families=self.font_families,
              font_properties=self.font_properties,
          )
      if val_texts:
          self.draw_texts(
              val_texts,
              (bboxes[val_index, :2] + bboxes[val_index, 2:]) / 2,
              colors="k",
              horizontal_alignments="center",
              vertical_alignments="center",
              font_families=self.font_families,
              font_properties=self.font_properties,
          )
      self.draw_arrows(
          x_data,
          y_data,
          colors=arrow_colors,
          line_widths=0.3,
          arrow_tail_widths=0.05,
          arrow_head_widths=5,
          overhangs=1,
          arrow_shapes="full",
      )
      return self.get_image()
  
file_path: mmocr/mmocr/visualization/kie_visualizer.py
imports: import warnings
  from typing import Dict, List, Optional, Sequence, Union
  import mmcv
  import numpy
  import torch
  from matplotlib.collections import PatchCollection
  from matplotlib.patches import FancyArrow
  from mmengine.visualization import Visualizer
  from mmengine.visualization.utils import check_type, check_type_and_length, color_val_matplotlib, tensor2ndarray, value2list
  from mmocr.registry import VISUALIZERS
  from mmocr.structures import KIEDataSample
  from .base_visualizer import BaseLocalVisualizer
label_desc: Use image node_id 2 for calling the KIELocalVisualizer obj's underlying member method code with example usage: obj._draw_edge_label(image, edge_labels, bboxes, texts, arrow_colors) and returns: self