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_joint_llh(
      self,
      emissions: torch.Tensor,
      tags: torch.Tensor,
      mask: torch.Tensor,
  ) -> torch.Tensor:
      seq_len = emissions.shape[1]
  
      # Log-likelihood for a given input is calculated by using the known
      # correct tag for each timestep and its respective emission value.
      # Since actual tags for each time step is also known, sum of transition
      # probabilities is also calculated.
      # Sum of emission and transition probabilities gives the final score for
      # the input.
      llh = self.transitions[self.start_tag, tags[:, 0]].unsqueeze(1)
      llh += emissions[:, 0, :].gather(
          1, tags[:, 0].view(-1, 1)
      ) * mask[:, 0].unsqueeze(1)
  
      for idx in range(1, seq_len):
          old_state, new_state = (
              tags[:, idx - 1].view(-1, 1),
              tags[:, idx].view(-1, 1),
          )
          emission_scores = emissions[:, idx, :].gather(1, new_state)
          transition_scores = self.transitions[old_state, new_state]
          llh += (emission_scores + transition_scores) * mask[
              :, idx
          ].unsqueeze(1)
  
      # Index of the last tag is calculated by taking the sum of mask matrix
      # for each input row and subtracting 1 from the sum.
      last_tag_indices = mask.sum(1, dtype=torch.long) - 1
      last_tags = tags.gather(1, last_tag_indices.view(-1, 1))
  
      llh += self.transitions[
          last_tags.squeeze(1), self.end_tag
      ].unsqueeze(1)
  
      return llh.squeeze(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 7 for calling the CRF obj's underlying member method code with example usage: obj._compute_joint_llh(emissions, tags, mask) and returns: llh