class_docstr: Compute the log-likelihood of the input assuming a conditional random field
  model.
  
  Args:
      num_tags: The number of tags
class_docstr_tok: ["Compute","the","log-likelihood","of","the","input","assuming","a","conditional","random","field","model",".","Args",":","num_tags",":","The","number","of","tags"]
code: def _compute_log_partition_function(
      self, emissions: torch.Tensor, mask: torch.Tensor
  ) -> torch.Tensor:
      seq_len = emissions.shape[1]
  
      log_prob = emissions[:, 0].clone()
      log_prob += self.transitions[
          self.start_tag, : self.start_tag
      ].unsqueeze(0)
  
      for idx in range(1, seq_len):
          broadcast_emissions = emissions[:, idx].unsqueeze(1)
          broadcast_transitions = self.transitions[
              : self.start_tag, : self.start_tag
          ].unsqueeze(0)
          broadcast_logprob = log_prob.unsqueeze(2)
          score = (
              broadcast_logprob
              + broadcast_emissions
              + broadcast_transitions
          )
  
          score = torch.logsumexp(score, 1)
          log_prob = score * mask[:, idx].unsqueeze(
              1
          ) + log_prob.squeeze(1) * (1 - mask[:, idx].unsqueeze(1))
  
      log_prob += self.transitions[
          : self.start_tag, self.end_tag
      ].unsqueeze(0)
      return torch.logsumexp(log_prob.squeeze(1), 1)
  
imports: from typing import List
  import torch
  import torch.jit
  import torch.nn
  from caffe2.python.crf_predict import apply_crf
  from pytext.utils.usage import log_class_usage
label_desc: Use image node_id 8 for calling the CRF obj's underlying member method code with example usage: obj._compute_log_partition_function(emissions, mask) and returns: torch