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
code: def __init__(self, num_tags: int, batch_first: bool = False) -> None:
      if num_tags <= 0:
          raise ValueError(f"invalid number of tags: {num_tags}")
      super().__init__()
      self.num_tags = num_tags
      self.batch_first = batch_first
      self.start_transitions = nn.Parameter(torch.empty(num_tags))
      self.end_transitions = nn.Parameter(torch.empty(num_tags))
      self.transitions = nn.Parameter(torch.empty(num_tags, num_tags))
  
      self.reset_parameters()
  
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 1 to create a new CRF object from inherited base classes: nn with example: obj = CRF(num_tags, batch_first)