code: def plot_structure(
      sm: nx.DiGraph,
      all_node_attributes: Dict[str, str] = None,
      all_edge_attributes: Dict[str, str] = None,
      node_attributes: Dict[str, Dict[str, str]] = None,
      edge_attributes: Dict[Tuple[str, str], Dict[str, str]] = None,
      plot_options: Dict[str, str] = None,
  ) -> Network:
      """
      Plot a `StructureModel` using pyvis.
  
      Return a pyvis graph object - which can be visualized using the pyvis method
      `.show(name)`
  
      Default node, edge, and graph attributes are provided to style and layout
      the plot. These defaults can be overridden for all nodes and edges through
      `all_node_attributes` and `all_edge_attributes` respectively. Graph
      attributes can be overridden through `graph_attributes`.
  
      Styling and layout attributes can be set for individual nodes and edges
      through `node_attributes` and `edge_attributes` respectively.
  
      Attributes are set in the following order, overriding any previously set attributes
      1. default attributes
      2. all_node_attributes and all_edge_attributes
      3. node_attributes and edge_attributes
  
      Detailed documentation on available attributes and how they behave is available at:
      https://visjs.github.io/vis-network/docs/network/.
  
      Default style attributes provided in CausalNex are:
  
      - causalnex.plots.GRAPH_STYLE - defaults graph styling
  
      - causalnex.plots.NODE_STYLE.NORMAL - default node styling
      - causalnex.plots.NODE_STYLE.WEAK - intended for less important nodes in structure
      - causalnex.plots.NODE_STYLE.STRONG - intended for more important nodes in structure
  
      - causalnex.plots.EDGE_STYLE.NORMAL - default edge styling
      - causalnex.plots.EDGE_STYLE.WEAK - intended for less important edges in structure
      - causalnex.plots.EDGE_STYLE.STRONG - intended for more important edges in structure
      Example:
      ::
          >>> from causalnex.plots import plot_structure
          >>> plot = plot_structure(structure_model)
      Args:
          sm: structure to plot
          all_node_attributes: attributes to apply to all nodes
          all_edge_attributes: attrinbutes to apply to all edges
          node_attributes: attributes to apply to specific nodes
          edge_attributes: attributes to apply to specific edges
          plot_options: attributes to apply to pyvis plotting function
  
      Returns:
          a styled pyvis graph that can be rendered externally as an HTML object
  
      """
      node_attributes = node_attributes or {}
      edge_attributes = edge_attributes or {}
      all_edge_attributes = all_edge_attributes or {}
      all_node_attributes = all_node_attributes or {}
      plot_options = plot_options or {}
  
      pyvis_graph = Network(**{**GRAPH_STYLE, **plot_options})
  
      all_node_attributes = {**NODE_STYLE.NORMAL, **all_node_attributes}
      all_edge_attributes = {**EDGE_STYLE.NORMAL, **all_edge_attributes}
  
      for node, _ in sm.nodes(data=True):
          pyvis_graph.add_node(
              node,
              **{
                  **all_node_attributes,
                  "label": f"{node}",
                  **node_attributes.get(node, {}),
              },
          )
  
      # for each edge and its attributes in the networkx graph
      for source, target in sm.edges:
          pyvis_graph.add_edge(
              source,
              target,
              **{
                  **all_edge_attributes,
                  **edge_attributes.get((source, target), {}),
              },
          )
  
      return pyvis_graph
  
imports: from collections import namedtuple
  from typing import Dict, Tuple
  import networkx
  from pyvis.network import Network
label_desc: Use image node_id 1 for calling a global function with example usage: plot_structure(sm, all_node_attributes, all_edge_attributes, node_attributes, edge_attributes, plot_options) and returns: pyvis_graph