class_docstr: Conditional random field.
  This module implements a conditional random field [LMP01]_. The forward computation
  of this class computes the log likelihood of the given sequence of tags and
  emission score tensor. This class also has `~CRF.decode` method which finds
  the best tag sequence given an emission score tensor using `Viterbi algorithm`_.
  Args:
      num_tags: Number of tags.
      batch_first: Whether the first dimension corresponds to the size of a minibatch.
  Attributes:
      start_transitions (`~torch.nn.Parameter`): Start transition score tensor of size
          ``(num_tags,)``.
      end_transitions (`~torch.nn.Parameter`): End transition score tensor of size
          ``(num_tags,)``.
      transitions (`~torch.nn.Parameter`): Transition score tensor of size
          ``(num_tags, num_tags)``.
  .. [LMP01] Lafferty, J., McCallum, A., Pereira, F. (2001).
     "Conditional random fields: Probabilistic models for segmenting and
     labeling sequence data". *Proc. 18th International Conf. on Machine
     Learning*. Morgan Kaufmann. pp. 282–289.
  .. _Viterbi algorithm: https://en.wikipedia.org/wiki/Viterbi_algorithm
docstr: Find the most likely tag sequence using Viterbi algorithm.
  Args:
      emissions (`~torch.Tensor`): Emission score tensor of size
          ``(seq_length, batch_size, num_tags)`` if ``batch_first`` is ``False``,
          ``(batch_size, seq_length, num_tags)`` otherwise.
      mask (`~torch.ByteTensor`): Mask tensor of size ``(seq_length, batch_size)``
          if ``batch_first`` is ``False``, ``(batch_size, seq_length)`` otherwise.
  Returns:
      List of list containing the best tag sequence for each batch.
docstr_tok: ["Find","the","most","likely","tag","sequence","using","Viterbi","algorithm",".","Args",":","emissions","(","`","~torch.Tensor","`",")",":","Emission","score","tensor","of","size","``","(","seq_length",",","batch_size",",","num_tags",")","``","if","``","batch_first","``","is","``","False","``",",","``","(","batch_size",",","seq_length",",","num_tags",")","``","otherwise",".","mask","(","`","~torch.ByteTensor","`",")",":","Mask","tensor","of","size","``","(","seq_length",",","batch_size",")","``","if","``","batch_first","``","is","``","False","``",",","``","(","batch_size",",","seq_length",")","``","otherwise",".","Returns",":","List","of","list","containing","the","best","tag","sequence","for","each","batch","."]
code: def decode(
      self,
      emissions: torch.Tensor,
      mask: Optional[torch.ByteTensor] = None,
  ) -> List[List[int]]:
      """Find the most likely tag sequence using Viterbi algorithm.
      Args:
          emissions (`~torch.Tensor`): Emission score tensor of size
              ``(seq_length, batch_size, num_tags)`` if ``batch_first`` is ``False``,
              ``(batch_size, seq_length, num_tags)`` otherwise.
          mask (`~torch.ByteTensor`): Mask tensor of size ``(seq_length, batch_size)``
              if ``batch_first`` is ``False``, ``(batch_size, seq_length)`` otherwise.
      Returns:
          List of list containing the best tag sequence for each batch.
      """
      self._validate(emissions, mask=mask)
      if mask is None:
          mask = emissions.new_ones(
              emissions.shape[:2], dtype=torch.uint8
          )
  
      if self.batch_first:
          emissions = emissions.transpose(0, 1)
          mask = mask.transpose(0, 1)
  
      return self._viterbi_decode(emissions, mask)
  
file_path: nlp-architect/nlp_architect/nn/torch/layers/crf.py
imports: from typing import List, Optional
  import torch
  import torch.nn
label_desc: Use image node_id 5 for calling the CRF obj's underlying member method code with example usage: obj.decode(emissions, mask) and returns: self