code: def to_networkx(cls, spans):
      cur = 0
      N = spans.shape[1]
      n_nodes = int(spans.sum().item())
      cover = spans.nonzero().cpu()
      order = torch.argsort(cover[:, 2] - cover[:, 1])
      left = {}
      right = {}
      ordered = cover[order]
      label = ordered[:, 3]
      a = []
      b = []
      topo = [[] for _ in range(N)]
      for n in ordered:
          batch, i, j, _ = n.tolist()
          # G.add_node(cur, label=A)
          if i - j != 0:
              a.append(left[(batch, i)][0])
              a.append(right[(batch, j)][0])
              b.append(cur)
              b.append(cur)
              order = max(left[(batch, i)][1], right[(batch, j)][1]) + 1
          else:
              order = 0
          left[(batch, i)] = (cur, order)
          right[(batch, j)] = (cur, order)
          topo[order].append(cur)
          cur += 1
      indices = left
      return (n_nodes, a, b, label), indices, topo
  
file_path: pytorch-struct/torch_struct/cky.py
imports: import torch
  from .helpers import _Struct, Chart
label_desc: Use image node_id 7 for calling the CKY obj's underlying member method code with example usage: obj.to_networkx(cls, spans) and returns: n_nodes,  a,  b,  label,  indices,  topo