code: def decode(
      g,
      tau,
      threshold,
      use_gt,
      ids=None,
      global_edges=None,
      global_num_nodes=None,
      global_peaks=None,
  ):
      # Edge filtering with tau and density
      den_key = "density" if use_gt else "pred_den"
      g = g.local_var()
      g.edata["edge_dist"] = get_edge_dist(g, threshold)
      g.apply_edges(
          lambda edges: {
              "keep": (edges.src[den_key] > edges.dst[den_key]).long()
              * (edges.data["edge_dist"] < 1 - tau).long()
          }
      )
      eids = torch.where(g.edata["keep"] == 0)[0]
      ng = dgl.remove_edges(g, eids)
  
      # Tree generation
      ng.edata[dgl.EID] = torch.arange(ng.num_edges())
      treeg = tree_generation(ng)
      # Label propogation
      peaks, pred_labels = peak_propogation(treeg)
  
      if ids is None:
          return pred_labels, peaks
  
      # Merge with previous layers
      src, dst = treeg.edges()
      new_global_edges = (
          global_edges[0] + ids[src.numpy()].tolist(),
          global_edges[1] + ids[dst.numpy()].tolist(),
      )
      global_treeg = dgl.graph(
          new_global_edges, num_nodes=global_num_nodes
      )
      global_peaks, global_pred_labels = peak_propogation(global_treeg)
      return (
          pred_labels,
          peaks,
          new_global_edges,
          global_pred_labels,
          global_peaks,
      )
  
file_path: dgl/examples/pytorch/hilander/utils/deduce.py
imports: import dgl
  import numpy
  import torch
  from sklearn import mixture
  from .density import density_to_peaks, density_to_peaks_vectorize
label_desc: Use image node_id 9 for calling a global function with example usage: decode(g, tau, threshold, use_gt, ids, global_edges, global_num_nodes, global_peaks) and returns: pred_labels,  peaks,  new_global_edges,  global_pred_labels,  global_peaks, pred_labels,  peaks