code: def sgraph2dot(
      sgraph, display_param_nodes=False, rankdir="TB", styles=None
  ):
      """Create a PNG object containing a graphiz-dot graph of the network,
      as represented by SummaryGraph 'sgraph'.
      Args:
          sgraph (SummaryGraph): the SummaryGraph instance to draw.
          display_param_nodes (boolean): if True, draw the parameter nodes
          rankdir: diagram direction.  'TB'/'BT' is Top-to-Bottom/Bottom-to-Top
                   'LR'/'R/L' is Left-to-Rt/Rt-to-Left
          styles: a dictionary of styles.  Key is module name.  Value is
                  a legal pydot style dictionary.  For example:
                  styles['conv1'] = {'shape': 'oval',
                                     'fillcolor': 'gray',
                                     'style': 'rounded, filled'}
      """
  
      def annotate_op_node(op):
          if op["type"] == "Conv":
              return [
                  "sh={}".format(
                      distiller.size2str(op["attrs"]["kernel_shape"])
                  ),
                  "g={}".format(str(op["attrs"]["group"])),
              ]
          return ""
  
      op_nodes = [op["name"] for op in sgraph.ops.values()]
      data_nodes = []
      param_nodes = []
      for id, param in sgraph.params.items():
          n_data = (
              id,
              str(distiller.volume(param["shape"])),
              str(param["shape"]),
          )
          if data_node_has_parent(sgraph, id):
              data_nodes.append(n_data)
          else:
              param_nodes.append(n_data)
      edges = sgraph.edges
  
      if not display_param_nodes:
          # Use only the edges that don't have a parameter source
          non_param_ids = op_nodes + [dn[0] for dn in data_nodes]
          edges = [
              edge for edge in sgraph.edges if edge.src in non_param_ids
          ]
          param_nodes = None
  
      op_nodes_desc = [
          (op["name"], op["type"], *annotate_op_node(op))
          for op in sgraph.ops.values()
      ]
      pydot_graph = create_pydot_graph(
          op_nodes_desc, data_nodes, param_nodes, edges, rankdir, styles
      )
      return pydot_graph
  
file_path: tensorwatch/tensorwatch/model_graph/hiddenlayer/pytorch_draw_model.py
imports: import pydot
  from .summary_graph import SummaryGraph
  from .None import distiller
  import torch
  import collections.abc
  import os
label_desc: Use image node_id 4 for calling a global function with example usage: sgraph2dot(sgraph, display_param_nodes, rankdir, styles) and returns: pydot_graph, str, list