code: def _visualize_graph_via_graphviz(
      edge_index: Tensor,
      edge_weight: Tensor,
      path: Optional[str] = None,
  ) -> Any:
      import graphviz
  
      suffix = path.split(".")[-1] if path is not None else None
      g = graphviz.Digraph("graph", format=suffix)
      g.attr("node", shape="circle", fontsize="11pt")
  
      for node in edge_index.view(-1).unique().tolist():
          g.node(str(node))
  
      for (src, dst), w in zip(
          edge_index.t().tolist(), edge_weight.tolist()
      ):
          hex_color = hex(255 - round(255 * w))[2:]
          hex_color = (
              f"{hex_color}0" if len(hex_color) == 1 else hex_color
          )
          g.edge(
              str(src),
              str(dst),
              color=f"#{hex_color}{hex_color}{hex_color}",
          )
  
      if path is not None:
          path = ".".join(path.split(".")[:-1])
          g.render(path, cleanup=True)
      else:
          g.view()
  
      return g
  
imports: from math import sqrt
  from typing import Any, Optional
  import torch
  from torch import Tensor
label_desc: Use image node_id 3 for calling a global function with example usage: _visualize_graph_via_graphviz(edge_index, edge_weight, path) and returns: g