code: def viz_schedule_tree(
      sch, show_svg=False, dot_file_path="", output_dot_string=False
  ):
      """Top level API to render schedule tree
  
      Parameters
      ----------
      sch : schedule
                  The schedule object to visualize
  
      show_svg : bool
                  Display graph as SVG, useful for Jupyter notebooks.
  
      dot_file_path : string
                  Dot file to save the graph.
  
      output_dot_string : bool
                  Return dot file content or an empty string.
  
      Returns
      -------
      dot_string : string
          Dot file content or an empty string according to output_dot_string
  
      Examples
      --------
      The following code writes a schedule tree to a dot file.
  
      .. code-block:: python
          tedd.viz_schedule_tree(s, dot_file_path = '/tmp/example.dot')
  
      Use the following code to render a SVG graph in a Jupyter notebook.
  
      .. code-block:: python
          tedd.viz_schedule_tree(s, show_svg = True)
      """
  
      def create_schedule_tree_graph(name=""):
          return create_graph(name=name, rankdir="BT")
  
      def root_dot(g):
          g.node("ROOT", "ROOT", shape="oval", margin="0")
  
      def stage_node_dot(g, stage):
          node_label = stage_node_label(stage)
          g.node(stage["id"], node_label, shape="none", margin="0")
  
      def stage_node_label(stage):
          """Return a html format label for the given stage."""
          label = (
              '<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" '
              'CELLPADDING="4"> <TR><TD BGCOLOR="lightgrey" '
              'COLSPAN="2" PORT="stage">'
              + stage_label(stage)
              + "</TD></TR>"
          )
  
          for leafiv in leaf_itervars(stage):
              iv_type = leafiv["itervar_type"]
              var_attr_label = ""
              if (
                  "thread" in leafiv["properties"]
                  and leafiv["properties"]["thread"] is not None
              ):
                  var_attr_label = (
                      var_attr_label
                      + '<br/><font color="#2980B9">('
                      + str(leafiv["properties"]["thread"])
                      + ")</font>"
                  )
              if (
                  "intrin" in leafiv["properties"]
                  and leafiv["properties"]["intrin"] is not None
              ):
                  var_attr_label = (
                      var_attr_label
                      + "<br/>"
                      + linebrk(
                          "(tensor_intrin:"
                          + str(leafiv["properties"]["intrin"])
                          + ")",
                          TVMDD_TABLE_BODY_WIDTH,
                      )
                  )
              var_label, color = get_itervar_label_color(
                  leafiv, iv_type
              )
              label += itervar_label(
                  leafiv,
                  leafiv["index"],
                  color,
                  var_label + var_attr_label,
              )
          if stage["compute"] is not None:
              label += (
                  '<TR><TD COLSPAN="2">'
                  + linebrk(
                      str(stage["compute"]), TVMDD_TABLE_BODY_WIDTH
                  )
                  + "</TD></TR>"
              )
          label += "</TABLE>>"
          return label
  
      def compute_at_dot(g, stage):
          """If the given stage attaches to another stage, create an edge from it
          stage to its attach point; otherwise, create an edge to the ROOT.
          """
          src = stage["id"]
          dst = (
              dom_path_to_string([stage["attaching_to"][0]], "Stage")
              + ":"
              + dom_path_to_string(stage["attaching_to"], "IterVar")
              if stage["attaching_to"] is not None
              else "ROOT"
          )
          color = (
              PALETTE[stage["attaching_to"][1] + 1]
              if stage["attaching_to"] is not None
              and stage["attaching_to"][1] < PALETTE_SIZE - 1
              else PALETTE[0]
          )
          g.edge(src, dst, color=color)
  
      graph = create_schedule_tree_graph("Schedule Tree")
      s = extract_dom_for_viz(sch)
      legend_dot(graph)
      for stage in s["stages"]:
          stage_node_dot(graph, stage)
      for stage in s["stages"]:
          compute_at_dot(graph, stage)
      root_dot(graph)
      return dump_graph(
          graph.source, show_svg, dot_file_path, output_dot_string
      )
  
imports: import html
  import json
  import warnings
  from graphviz import Digraph
  from graphviz import Source
  import tvm
label_desc: Use image node_id 18 for calling a global function with example usage: viz_schedule_tree(sch, show_svg, dot_file_path, output_dot_string) and returns: dump_graph, create_graph, label