code: def analyse_pir(program):
      from paddle.utils.unique_name import generate
  
      all_ops = {}
      all_vars = {}
      all_edges = {}
      # vars info
      for op in program.global_block().ops:
          var_name = utils.gen_var_name(op.results())
          all_vars[var_name] = {}
          all_vars[var_name]["name"] = var_name
          attrs = op.results()[0].get_defining_op().attrs()
  
          if "place" in attrs:
              attrs["place"] = str(attrs["place"])
          attrs["dtype"] = op.result(0).dtype.name
  
          all_vars[var_name]["shape"] = op.result(0).shape
          all_vars[var_name]["type"] = op.result(0).dtype.name
          all_vars[var_name]["dtype"] = op.result(0).dtype.name
  
          all_vars[var_name]["value"] = []
          all_vars[var_name]["persistable"] = op.result(
              0
          ).is_persistable
          all_vars[var_name]["attrs"] = attrs
          all_vars[var_name]["from_node"] = ""
          all_vars[var_name]["to_nodes"] = []
  
      # ops info
      for op in program.global_block().ops:
          op_name = generate(op.name())
  
          if op.num_operands() > 0:
              all_ops[op_name] = {}
              all_ops[op_name]["name"] = op_name
              all_ops[op_name]["show_name"] = op_name
              all_ops[op_name]["type"] = op.result(0).dtype.name
              all_ops[op_name]["dtype"] = op.result(0).dtype.name
  
              all_ops[op_name]["input_vars"] = {}
              all_ops[op_name]["output_vars"] = {}
  
              all_ops[op_name]["is_leaf_node"] = True
              now_var = utils.gen_var_name(op.results())
              for source in op.operands_source():
                  input_name = utils.gen_var_name(source)
                  all_ops[op_name]["input_vars"][input_name] = [
                      input_name
                  ]
                  all_vars[input_name]["to_nodes"].append(op_name)
              all_vars[now_var]["from_node"] = op_name
              all_ops[op_name]["output_vars"][now_var] = [now_var]
  
              all_ops[op_name]["attrs"] = attrs
              all_ops[op_name]["attr_types"] = attrs
              all_ops[op_name]["children_node"] = []
              all_ops[op_name]["input_nodes"] = []
              all_ops[op_name]["output_nodes"] = []
              all_ops[op_name]["edge_input_nodes"] = []
              all_ops[op_name]["edge_output_nodes"] = []
  
      # create '/' op
      all_ops["/"] = {}
      all_ops["/"]["name"] = "/"
      all_ops["/"]["show_name"] = "/"
      all_ops["/"]["type"] = ""
      all_ops["/"]["attrs"] = {}
      all_ops["/"]["input_vars"] = {}
      all_ops["/"]["output_vars"] = {}
      all_ops["/"]["is_leaf_node"] = False
      all_ops["/"]["children_node"] = []
      for node in all_ops:
          if node != "/":
              all_ops["/"]["children_node"].append(node)
  
      for variable_name in all_vars:
          if all_vars[variable_name]["from_node"] == "":
              continue
          from_node_name = all_vars[variable_name]["from_node"]
          for to_node_name in all_vars[variable_name]["to_nodes"]:
              if to_node_name != from_node_name:
                  all_ops[from_node_name]["output_nodes"].append(
                      to_node_name
                  )
                  all_ops[to_node_name]["input_nodes"].append(
                      from_node_name
                  )
  
      # edge info
      # TODO(Difers):add edge info in future
  
      final_data = {
          "version": _graph_version,
          "nodes": list(all_ops.values()),
          "vars": list(all_vars.values()),
          "edges": list(all_edges.values()),
      }
      return final_data
  
file_path: VisualDL/visualdl/component/graph/graph_component.py
imports: import collections
  import os.path
  import pathlib
  import re
  from .None import utils
label_desc: Use image node_id 5 for calling a global function with example usage: analyse_pir(program) and returns: final_data