code: def from_parts(chart):
      terms, rules, roots = chart
      batch, N, N, NT, S, S = rules.shape
      assert terms.shape[1] == N
  
      spans = torch.zeros(
          batch, N, N, S, dtype=rules.dtype, device=rules.device
      )
      rules = rules.sum(dim=-1).sum(dim=-1)
      for n in range(N):
          spans[
              :, torch.arange(N - n - 1), torch.arange(n + 1, N), :NT
          ] = rules[:, n, torch.arange(N - n - 1)]
      spans[:, torch.arange(N), torch.arange(N), NT:] = terms
      return spans, (NT, S - NT)
  
file_path: pytorch-struct/torch_struct/cky.py
imports: import torch
  from .helpers import _Struct, Chart
label_desc: Use image node_id 5 for calling the CKY obj's underlying member method code with example usage: obj.from_parts(chart) and returns: spans,  NT,  unknown