class_docstr: Render dependency parses as SVGs.
class_docstr_tok: ["Render","dependency","parses","as","SVGs","."]
docstr: Calculate available arc height "levels".
  Used to calculate arrow heights dynamically and without wasting space.
  
  args (list): Individual arcs and their start, end, direction and label.
  RETURNS (dict): Arc levels keyed by (start, end, label).
docstr_tok: ["Calculate","available","arc","height","``","levels","''",".","Used","to","calculate","arrow","heights","dynamically","and","without","wasting","space",".","args","(","list",")",":","Individual","arcs","and","their","start",",","end",",","direction","and","label",".","RETURNS","(","dict",")",":","Arc","levels","keyed","by","(","start",",","end",",","label",")","."]
code: def get_levels(
      self, arcs: List[Dict[str, Any]]
  ) -> Dict[Tuple[int, int, str], int]:
      """Calculate available arc height "levels".
      Used to calculate arrow heights dynamically and without wasting space.
  
      args (list): Individual arcs and their start, end, direction and label.
      RETURNS (dict): Arc levels keyed by (start, end, label).
      """
      arcs = [
          dict(t) for t in {tuple(sorted(arc.items())) for arc in arcs}
      ]
      length = max([arc["end"] for arc in arcs], default=0)
      max_level = [0] * length
      levels = {}
      for arc in sorted(
          arcs, key=lambda arc: arc["end"] - arc["start"]
      ):
          level = max(max_level[arc["start"] : arc["end"]]) + 1
          for i in range(arc["start"], arc["end"]):
              max_level[i] = level
          levels[(arc["start"], arc["end"], arc["label"])] = level
      return levels
  
imports: import uuid
  from typing import Any, Dict, List, Optional, Tuple, Union
  from ..errors import Errors
  from ..util import escape_html, minify_html, registry
  from .templates import TPL_DEP_ARCS, TPL_DEP_SVG, TPL_DEP_WORDS, TPL_DEP_WORDS_LEMMA, TPL_ENT, TPL_ENT_RTL, TPL_ENTS, TPL_FIGURE, TPL_KB_LINK, TPL_PAGE, TPL_SPAN, TPL_SPAN_RTL, TPL_SPAN_SLICE, TPL_SPAN_SLICE_RTL, TPL_SPAN_START, TPL_SPAN_START_RTL, TPL_SPANS, TPL_TITLE
label_desc: Use image node_id 8 for calling the DependencyRenderer obj's underlying member method code with example usage: obj.get_levels(arcs) and returns: levels