class_docstr: Calculate log-space crf loss, given unary potentials, a transition matrix
  and gold tag sequences.
class_docstr_tok: ["Calculate","log-space","crf","loss",",","given","unary","potentials",",","a","transition","matrix","and","gold","tag","sequences","."]
docstr: @return:
      unary_scores: batch_size
docstr_tok: ["@","return",":","unary_scores",":","batch_size"]
code: def crf_unary_score(
      self, inputs, masks, tag_indices, input_bs, input_sl, input_nc
  ):
      """
      @return:
          unary_scores: batch_size
      """
      flat_inputs = inputs.view(input_bs, -1)
      flat_tag_indices = (
          tag_indices
          + torch.arange(input_sl, device=tag_indices.device)
          .long()
          .unsqueeze(0)
          * input_nc
      )
      unary_scores = torch.gather(
          flat_inputs, 1, flat_tag_indices
      ).view(input_bs, -1)
      unary_scores.masked_fill_(masks, 0)
      return unary_scores.sum(dim=1)
  
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 3 for calling the CRFLoss obj's underlying member method code with example usage: obj.crf_unary_score(inputs, masks, tag_indices, input_bs, input_sl, input_nc) and returns: unary_scores