code: def viterbi_decode(scores, transition_params):
      """
      Decode a tag sequence with viterbi algorithm.
      scores: seq_len x num_tags (numpy array)
      transition_params: num_tags x num_tags (numpy array)
      @return:
          viterbi: a list of tag ids with highest score
          viterbi_score: the highest score
      """
      trellis = np.zeros_like(scores)
      backpointers = np.zeros_like(scores, dtype=np.int32)
      trellis[0] = scores[0]
  
      for t in range(1, scores.shape[0]):
          v = np.expand_dims(trellis[t - 1], 1) + transition_params
          trellis[t] = scores[t] + np.max(v, 0)
          backpointers[t] = np.argmax(v, 0)
  
      viterbi = [np.argmax(trellis[-1])]
      for bp in reversed(backpointers[1:]):
          viterbi.append(bp[viterbi[-1]])
      viterbi.reverse()
      viterbi_score = np.max(trellis[-1])
      return viterbi, viterbi_score
  
file_path: stanza/stanza/models/common/crf.py
imports: import math
  from numbers import Number
  import numpy
  import torch
  from torch import nn
  import torch.nn.init
label_desc: Use image node_id 1 for calling a global function with example usage: viterbi_decode(scores, transition_params) and returns: viterbi,  viterbi_score