code: def visual_mode(
      mode_type="netron",
      pattern_name=None,
      pattern_idx=0,
      graph_path=None,
  ):
      def get_graph_def(
          pattern_name=None, pattern_idx=0, graph_path=None
      ):
          assert (pattern_name is not None) or (
              graph_path is not None
          ), "pattern_name or graph_path should at least have one is None and the other is not."
          if graph_path is not None:
              name = graph_path.split("/")[-1]
              with open(graph_path, "rb") as f:
                  graph_def = tf.GraphDef()
                  graph_def.ParseFromString(f.read())
          else:
              name = pattern_name
              graph_def = RegistPattern.get_patterns(pattern_name)[
                  pattern_idx
              ]
          return graph_def, name
  
      graph_def, name = get_graph_def(
          pattern_name=pattern_name,
          pattern_idx=pattern_idx,
          graph_path=graph_path,
      )
      if mode_type == "netron":
          tmp_dir = tempfile.mkdtemp()
          model_path = tmp_dir + "/" + name
          with open(model_path, "wb") as f:
              f.write(graph_def.SerializeToString())
          netron.start(
              file=model_path,
              host=get_ip_address(),
              port=flags.FLAGS.pt,
          )
          shutil.rmtree(tmp_dir)
  
      else:  # type == 'tf'
          with Session() as sess:
              tmp_dir = tempfile.mkdtemp()
              tf.import_graph_def(graph_def)
              train_writer = summary.FileWriter(tmp_dir)
              train_writer.add_graph(sess.graph)
              train_writer.flush()
              train_writer.close()
              tb = program.TensorBoard(default.get_plugins())
              tb.configure(
                  argv=[
                      None,
                      "--logdir",
                      tmp_dir,
                      "--port",
                      flags.FLAGS.pt,
                      "--host",
                      get_ip_address(),
                  ]
              )
              tb.main()
              shutil.rmtree(tmp_dir)
  
file_path: delta/gcompiler/python/delta_infer/visual_pattern.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import sys
  import socket
  import tempfile
  import shutil
  import netron
  import tensorflow
  from tensorboard import program, default
  from absl import app
  from absl import flags
  from .subgraphs import *
label_desc: Use image node_id 2 for calling a global function with example usage: visual_mode(mode_type, pattern_name, pattern_idx, graph_path) and returns: graph_def,  name