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 single or multiple arrows.
  
  Args:
      x_data (np.ndarray or torch.Tensor): The x coordinate of
          each line' start and end points.
      y_data (np.ndarray, torch.Tensor): The y coordinate of
          each line' start and end points.
      colors (str or tuple or list[str or tuple]): The colors of
          lines. ``colors`` can have the same length with lines or just
          single value. If ``colors`` is single value, all the lines
          will have the same colors. Reference to
          https://matplotlib.org/stable/gallery/color/named_colors.html
          for more details. Defaults to 'g'.
      line_widths (int or float or list[int or float]):
          The linewidth of lines. ``line_widths`` can have
          the same length with lines or just single value.
          If ``line_widths`` is single value, all the lines will
          have the same linewidth. Defaults to 2.
      line_styles (str or list[str]]): The linestyle of lines.
          ``line_styles`` can have the same length with lines or just
          single value. If ``line_styles`` is single value, all the
          lines will have the same linestyle. Defaults to '-'.
      arrow_tail_widths (int or float or list[int, float]):
          The width of arrow tails. ``arrow_tail_widths`` can have
          the same length with lines or just single value. If
          ``arrow_tail_widths`` is single value, all the lines will
          have the same width. Defaults to 0.001.
      arrow_head_widths (int or float or list[int, float]):
          The width of arrow heads. ``arrow_head_widths`` can have
          the same length with lines or just single value. If
          ``arrow_head_widths`` is single value, all the lines will
          have the same width. Defaults to None.
      arrow_head_lengths (int or float or list[int, float]):
          The length of arrow heads. ``arrow_head_lengths`` can have
          the same length with lines or just single value. If
          ``arrow_head_lengths`` is single value, all the lines will
          have the same length. Defaults to None.
      arrow_shapes (str or list[str]]): The shapes of arrow heads.
          ``arrow_shapes`` can have the same length with lines or just
          single value. If ``arrow_shapes`` is single value, all the
          lines will have the same shape. Defaults to 'full'.
      overhangs (int or list[int]]): The overhangs of arrow heads.
          ``overhangs`` can have the same length with lines or just
          single value. If ``overhangs`` is single value, all the lines
          will have the same overhangs. Defaults to 0.
docstr_tok: ["Draw","single","or","multiple","arrows",".","Args",":","x_data","(","np.ndarray","or","torch.Tensor",")",":","The","x","coordinate","of","each","line","'","start","and","end","points",".","y_data","(","np.ndarray",",","torch.Tensor",")",":","The","y","coordinate","of","each","line","'","start","and","end","points",".","colors","(","str","or","tuple","or","list","[","str","or","tuple","]",")",":","The","colors","of","lines",".","``","colors","``","can","have","the","same","length","with","lines","or","just","single","value",".","If","``","colors","``","is","single","value",",","all","the","lines","will","have","the","same","colors",".","Reference","to","https",":","\/\/matplotlib.org\/stable\/gallery\/color\/named_colors.html","for","more","details",".","Defaults","to","'","g","'",".","line_widths","(","int","or","float","or","list","[","int","or","float","]",")",":","The","linewidth","of","lines",".","``","line_widths","``","can","have","the","same","length","with","lines","or","just","single","value",".","If","``","line_widths","``","is","single","value",",","all","the","lines","will","have","the","same","linewidth",".","Defaults","to","2.","line_styles","(","str","or","list","[","str","]","]",")",":","The","linestyle","of","lines",".","``","line_styles","``","can","have","the","same","length","with","lines","or","just","single","value",".","If","``","line_styles","``","is","single","value",",","all","the","lines","will","have","the","same","linestyle",".","Defaults","to","'-","'",".","arrow_tail_widths","(","int","or","float","or","list","[","int",",","float","]",")",":","The","width","of","arrow","tails",".","``","arrow_tail_widths","``","can","have","the","same","length","with","lines","or","just","single","value",".","If","``","arrow_tail_widths","``","is","single","value",",","all","the","lines","will","have","the","same","width",".","Defaults","to","0.001.","arrow_head_widths","(","int","or","float","or","list","[","int",",","float","]",")",":","The","width","of","arrow","heads",".","``","arrow_head_widths","``","can","have","the","same","length","with","lines","or","just","single","value",".","If","``","arrow_head_widths","``","is","single","value",",","all","the","lines","will","have","the","same","width",".","Defaults","to","None",".","arrow_head_lengths","(","int","or","float","or","list","[","int",",","float","]",")",":","The","length","of","arrow","heads",".","``","arrow_head_lengths","``","can","have","the","same","length","with","lines","or","just","single","value",".","If","``","arrow_head_lengths","``","is","single","value",",","all","the","lines","will","have","the","same","length",".","Defaults","to","None",".","arrow_shapes","(","str","or","list","[","str","]","]",")",":","The","shapes","of","arrow","heads",".","``","arrow_shapes","``","can","have","the","same","length","with","lines","or","just","single","value",".","If","``","arrow_shapes","``","is","single","value",",","all","the","lines","will","have","the","same","shape",".","Defaults","to","'full","'",".","overhangs","(","int","or","list","[","int","]","]",")",":","The","overhangs","of","arrow","heads",".","``","overhangs","``","can","have","the","same","length","with","lines","or","just","single","value",".","If","``","overhangs","``","is","single","value",",","all","the","lines","will","have","the","same","overhangs",".","Defaults","to","0","."]
code: def draw_arrows(
      self,
      x_data: Union[np.ndarray, torch.Tensor],
      y_data: Union[np.ndarray, torch.Tensor],
      colors: Union[str, tuple, List[str], List[tuple]] = "C1",
      line_widths: Union[
          Union[int, float], List[Union[int, float]]
      ] = 1,
      line_styles: Union[str, List[str]] = "-",
      arrow_tail_widths: Union[
          Union[int, float], List[Union[int, float]]
      ] = 0.001,
      arrow_head_widths: Union[
          Union[int, float], List[Union[int, float]]
      ] = None,
      arrow_head_lengths: Union[
          Union[int, float], List[Union[int, float]]
      ] = None,
      arrow_shapes: Union[str, List[str]] = "full",
      overhangs: Union[int, List[int]] = 0,
  ) -> "Visualizer":
      """Draw single or multiple arrows.
  
      Args:
          x_data (np.ndarray or torch.Tensor): The x coordinate of
              each line' start and end points.
          y_data (np.ndarray, torch.Tensor): The y coordinate of
              each line' start and end points.
          colors (str or tuple or list[str or tuple]): The colors of
              lines. ``colors`` can have the same length with lines or just
              single value. If ``colors`` is single value, all the lines
              will have the same colors. Reference to
              https://matplotlib.org/stable/gallery/color/named_colors.html
              for more details. Defaults to 'g'.
          line_widths (int or float or list[int or float]):
              The linewidth of lines. ``line_widths`` can have
              the same length with lines or just single value.
              If ``line_widths`` is single value, all the lines will
              have the same linewidth. Defaults to 2.
          line_styles (str or list[str]]): The linestyle of lines.
              ``line_styles`` can have the same length with lines or just
              single value. If ``line_styles`` is single value, all the
              lines will have the same linestyle. Defaults to '-'.
          arrow_tail_widths (int or float or list[int, float]):
              The width of arrow tails. ``arrow_tail_widths`` can have
              the same length with lines or just single value. If
              ``arrow_tail_widths`` is single value, all the lines will
              have the same width. Defaults to 0.001.
          arrow_head_widths (int or float or list[int, float]):
              The width of arrow heads. ``arrow_head_widths`` can have
              the same length with lines or just single value. If
              ``arrow_head_widths`` is single value, all the lines will
              have the same width. Defaults to None.
          arrow_head_lengths (int or float or list[int, float]):
              The length of arrow heads. ``arrow_head_lengths`` can have
              the same length with lines or just single value. If
              ``arrow_head_lengths`` is single value, all the lines will
              have the same length. Defaults to None.
          arrow_shapes (str or list[str]]): The shapes of arrow heads.
              ``arrow_shapes`` can have the same length with lines or just
              single value. If ``arrow_shapes`` is single value, all the
              lines will have the same shape. Defaults to 'full'.
          overhangs (int or list[int]]): The overhangs of arrow heads.
              ``overhangs`` can have the same length with lines or just
              single value. If ``overhangs`` is single value, all the lines
              will have the same overhangs. Defaults to 0.
      """
      check_type("x_data", x_data, (np.ndarray, torch.Tensor))
      x_data = tensor2ndarray(x_data)
      check_type("y_data", y_data, (np.ndarray, torch.Tensor))
      y_data = tensor2ndarray(y_data)
      assert (
          x_data.shape == y_data.shape
      ), "`x_data` and `y_data` should have the same shape"
      assert (
          x_data.shape[-1] == 2
      ), f"The shape of `x_data` should be (N, 2), but got {x_data.shape}"
      if len(x_data.shape) == 1:
          x_data = x_data[None]
          y_data = y_data[None]
      number_arrow = x_data.shape[0]
      check_type_and_length(
          "colors", colors, (str, tuple, list), number_arrow
      )
      colors = value2list(colors, (str, tuple), number_arrow)
      colors = color_val_matplotlib(colors)  # type: ignore
      check_type_and_length(
          "line_widths", line_widths, (int, float), number_arrow
      )
      line_widths = value2list(line_widths, (int, float), number_arrow)
      check_type_and_length(
          "arrow_tail_widths",
          arrow_tail_widths,
          (int, float),
          number_arrow,
      )
      check_type_and_length(
          "line_styles", line_styles, str, number_arrow
      )
      line_styles = value2list(line_styles, str, number_arrow)
      arrow_tail_widths = value2list(
          arrow_tail_widths, (int, float), number_arrow
      )
      check_type_and_length(
          "arrow_head_widths",
          arrow_head_widths,
          (int, float, type(None)),
          number_arrow,
      )
      arrow_head_widths = value2list(
          arrow_head_widths, (int, float, type(None)), number_arrow
      )
      check_type_and_length(
          "arrow_head_lengths",
          arrow_head_lengths,
          (int, float, type(None)),
          number_arrow,
      )
      arrow_head_lengths = value2list(
          arrow_head_lengths, (int, float, type(None)), number_arrow
      )
      check_type_and_length(
          "arrow_shapes", arrow_shapes, (str, list), number_arrow
      )
      arrow_shapes = value2list(arrow_shapes, (str, list), number_arrow)
      check_type("overhang", overhangs, int)
      overhangs = value2list(overhangs, int, number_arrow)
  
      lines = np.concatenate(
          (x_data.reshape(-1, 2, 1), y_data.reshape(-1, 2, 1)), axis=-1
      )
      if not self._is_posion_valid(lines):
          warnings.warn(
              "Warning: The line is out of bounds,"
              " the drawn line may not be in the image",
              UserWarning,
          )
      arrows = []
      for i in range(number_arrow):
          arrows.append(
              FancyArrow(
                  *tuple(lines[i, 0]),
                  *tuple(lines[i, 1] - lines[i, 0]),
                  linestyle=line_styles[i],
                  color=colors[i],
                  length_includes_head=True,
                  width=arrow_tail_widths[i],
                  head_width=arrow_head_widths[i],
                  head_length=arrow_head_lengths[i],
                  overhang=overhangs[i],
                  shape=arrow_shapes[i],
                  linewidth=line_widths[i],
              )
          )
      p = PatchCollection(arrows, match_original=True)
      self.ax_save.add_collection(p)
      return self
  
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 5 for calling the KIELocalVisualizer obj's underlying member method code with example usage: obj.draw_arrows(x_data, y_data, colors, line_widths, line_styles, arrow_tail_widths, arrow_head_widths, arrow_head_lengths, arrow_shapes, overhangs) and returns: self