code: def _intermediary(spans):
      batch, N = spans.shape[:2]
      splits = {}
      cover = spans.nonzero()
      left, right = {}, {}
      for k in range(cover.shape[0]):
          b, i, j, A = cover[k].tolist()
          left.setdefault((b, i), [])
          right.setdefault((b, j), [])
          left[b, i].append((A, j, j - i + 1))
          right[b, j].append((A, i, j - i + 1))
  
      for x in range(cover.shape[0]):
          b, i, j, A = cover[x].tolist()
          if i == j:
              continue
          b_final = None
          c_final = None
          k_final = None
          for B_p, k, a_span in left.get((b, i), []):
              if k > j:
                  continue
              for C_p, k_2, b_span in right.get((b, j), []):
                  if k_2 == k + 1 and a_span + b_span == j - i + 1:
                      k_final = k
                      b_final = B_p
                      c_final = C_p
                      break
              if b_final is not None:
                  break
          assert k_final is not None, "%s %s %s %s" % (
              b,
              i,
              j,
              spans[b].nonzero(),
          )
          splits[(b, i, j)] = k_final, b_final, c_final
      return splits
  
file_path: pytorch-struct/torch_struct/cky.py
imports: import torch
  from .helpers import _Struct, Chart
label_desc: Use image node_id 6 for calling the CKY obj's underlying member method code with example usage: obj._intermediary(spans) and returns: splits