class_docstr: Represents structured linear-chain CRFs, generalizing HMMs smoothing, tagging models,
  and anything with chain-like dynamics.
docstr: Convert edges to sequence representation.
  
  Parameters:
      edge : b x (N-1) x C x C markov indicators
                  (t x z_t x z_{t-1})
  
  Returns:
      sequence : b x N long tensor in [0, C-1]
docstr_tok: ["Convert","edges","to","sequence","representation",".","Parameters",":","edge",":","b","x","(","N-1",")","x","C","x","C","markov","indicators","(","t","x","z_t","x","z_","{","t-1","}",")","Returns",":","sequence",":","b","x","N","long","tensor","in","[","0",",","C-1","]"]
code: def from_parts(edge):
      """
      Convert edges to sequence representation.
  
      Parameters:
          edge : b x (N-1) x C x C markov indicators
                      (t x z_t x z_{t-1})
  
      Returns:
          sequence : b x N long tensor in [0, C-1]
      """
      batch, N_1, C, _ = edge.shape
      N = N_1 + 1
      labels = torch.zeros(batch, N).long()
      on = edge.nonzero()
      for i in range(on.shape[0]):
          if on[i][1] == 0:
              labels[on[i][0], on[i][1]] = on[i][3]
          labels[on[i][0], on[i][1] + 1] = on[i][2]
      return labels, C
  
file_path: pytorch-struct/torch_struct/linearchain.py
imports: import torch
  from .helpers import _Struct
label_desc: Use image node_id 4 for calling the LinearChain obj's underlying member method code with example usage: obj.from_parts(edge) and returns: labels,  C