class_docstr: edge : b x N x K x C x C semimarkov potentials
docstr: Convert a edges to a sequence representation.
  
  Parameters:
      edge : b x (N-1) x K x C x C semimarkov potentials
              (t x z_t x z_{t-1})
  
  Returns:
      sequence : b x N  long tensors in [-1, 0, C-1]
docstr_tok: ["Convert","a","edges","to","a","sequence","representation",".","Parameters",":","edge",":","b","x","(","N-1",")","x","K","x","C","x","C","semimarkov","potentials","(","t","x","z_t","x","z_","{","t-1","}",")","Returns",":","sequence",":","b","x","N","long","tensors","in","[","-1",",","0",",","C-1","]"]
code: def from_parts(edge):
      """
      Convert a edges to a sequence representation.
  
      Parameters:
          edge : b x (N-1) x K x C x C semimarkov potentials
                  (t x z_t x z_{t-1})
  
      Returns:
          sequence : b x N  long tensors in [-1, 0, C-1]
  
      """
      batch, N_1, K, C, _ = edge.shape
      N = N_1 + 1
      labels = torch.zeros(batch, N).long().fill_(-1)
      on = edge.nonzero()
      for i in range(on.shape[0]):
          if on[i][1] == 0:
              labels[on[i][0], on[i][1]] = on[i][4]
          labels[on[i][0], on[i][1] + on[i][2]] = on[i][3]
      # print(edge.nonzero(), labels)
      return labels, (C, K)
  
file_path: pytorch-struct/torch_struct/semimarkov.py
imports: import torch
  from .helpers import _Struct
label_desc: Use image node_id 5 for calling the SemiMarkov obj's underlying member method code with example usage: obj.from_parts(edge) and returns: labels,  C,  K