code: def _crf_forward(
      self,
      input_blob,
      initial_state,
      transitions_copy,
      seq_lengths=None,
  ):
      # Build the RNN net and get the last timestep output
      out_last = self.build_crf_net(
          input_blob, initial_state, transitions_copy
      )
      out_last, _ = self.model.net.Reshape(
          [out_last], outputs=2, shape=(self.num_classes_padded,)
      )
      zero_segment_id = self.model.param_init_net.ConstantFill(
          [],
          value=0,
          shape=[self.num_classes_padded],
          dtype=core.DataType.INT32,
      )
  
      # Compute the accumulated total score of all the paths
      accum_score = self.model.net.SortedSegmentRangeLogSumExp(
          [out_last, zero_segment_id]
      )
      accum_score, _ = self.model.net.Reshape(
          accum_score, outputs=2, shape=()
      )
      return accum_score
  
file_path: pytorch/caffe2/python/crf.py
imports: import numpy
  from caffe2.python import brew, core, model_helper, recurrent
label_desc: Use image node_id 5 for calling the CRFWithLoss obj's underlying member method code with example usage: obj._crf_forward(input_blob, initial_state, transitions_copy, seq_lengths) and returns: accum_score