code: def visualize_graph(
      edge_index: Tensor,
      edge_weight: Optional[Tensor] = None,
      path: Optional[str] = None,
      backend: Optional[str] = None,
  ) -> Any:
      r"""Visualizes the graph given via :obj:`edge_index` and (optional)
      :obj:`edge_weight`.
  
      Args:
          edge_index (torch.Tensor): The edge indices.
          edge_weight (torch.Tensor, optional): The edge weights.
          path (str, optional): The path to where the plot is saved.
              If set to :obj:`None`, will visualize the plot on-the-fly.
              (default: :obj:`None`)
          backend (str, optional): The graph drawing backend to use for
              visualization (:obj:`"graphviz"`, :obj:`"networkx"`).
              If set to :obj:`None`, will use the most appropriate
              visualization backend based on available system packages.
              (default: :obj:`None`)
      """
      if edge_weight is not None:  # Normalize edge weights.
          edge_weight = edge_weight - edge_weight.min()
          edge_weight = edge_weight / edge_weight.max()
  
      if (
          edge_weight is not None
      ):  # Discard any edges with zero edge weight:
          mask = edge_weight > 1e-7
          edge_index = edge_index[:, mask]
          edge_weight = edge_weight[mask]
  
      if edge_weight is None:
          edge_weight = torch.ones(edge_index.size(1))
  
      if backend is None:
          backend = "graphviz" if has_graphviz() else "networkx"
  
      if backend.lower() == "networkx":
          return _visualize_graph_via_networkx(
              edge_index, edge_weight, path
          )
      elif backend.lower() == "graphviz":
          return _visualize_graph_via_graphviz(
              edge_index, edge_weight, path
          )
  
      raise ValueError(
          f"Expected graph drawing backend to be in "
          f"{BACKENDS} (got '{backend}')"
      )
  
imports: from math import sqrt
  from typing import Any, Optional
  import torch
  from torch import Tensor
label_desc: Use image node_id 2 for calling a global function with example usage: visualize_graph(edge_index, edge_weight, path, backend) and returns: _visualize_graph_via_networkx, _visualize_graph_via_graphviz