code: def extract_parse(span, length):
      tree = [(i, str(i)) for i in range(length)]
      tree = dict(tree)
      spans = []
      cover = (span > 0).float().nonzero()
      for i in range(cover.shape[0]):
          w, r, A = cover[i].tolist()
          w = w + 1
          r = r + w
          l = r - w
          spans.append((l, r, A))
          span = "({} {})".format(tree[l], tree[r])
          tree[r] = tree[l] = span
      return spans, tree[0]
  
imports: import torch
  from torch_struct import SentCFG
label_desc: Use image node_id 2 for calling a global function with example usage: extract_parse(span, length) and returns: spans,  tree