class_docstr: Conditional Random Field.
  
  Conditional Random Field Implementation according to sgrvinod (https://github.com/sgrvinod).
  Classifier which predicts single tag / class / label for given word based on not just the word,
  but also on previous seen annotations.
class_docstr_tok: ["Conditional","Random","Field",".","Conditional","Random","Field","Implementation","according","to","sgrvinod","(","https",":","\/\/github.com\/sgrvinod",")",".","Classifier","which","predicts","single","tag","\/","class","\/","label","for","given","word","based","on","not","just","the","word",",","but","also","on","previous","seen","annotations","."]
docstr: Initialize the Conditional Random Field.
  
  Args:
      tag_dictionary: tag dictionary in order to find ID for start and stop tags
      tagset_size: number of tag from tag dictionary
      init_from_state_dict: whether we load pretrained model from state dict
docstr_tok: ["Initialize","the","Conditional","Random","Field",".","Args",":","tag_dictionary",":","tag","dictionary","in","order","to","find","ID","for","start","and","stop","tags","tagset_size",":","number","of","tag","from","tag","dictionary","init_from_state_dict",":","whether","we","load","pretrained","model","from","state","dict"]
code: def __init__(
      self, tag_dictionary, tagset_size: int, init_from_state_dict: bool
  ) -> None:
      """Initialize the Conditional Random Field.
  
      Args:
          tag_dictionary: tag dictionary in order to find ID for start and stop tags
          tagset_size: number of tag from tag dictionary
          init_from_state_dict: whether we load pretrained model from state dict
      """
      super().__init__()
  
      self.tagset_size = tagset_size
      # Transitions are used in the following way: transitions[to, from].
      self.transitions = torch.nn.Parameter(
          torch.randn(tagset_size, tagset_size)
      )
      # If we are not using a pretrained model and train a fresh one, we need to set transitions from any tag
      # to START-tag and from STOP-tag to any other tag to -10000.
      if not init_from_state_dict:
          self.transitions.detach()[
              tag_dictionary.get_idx_for_item(START_TAG), :
          ] = -10000
  
          self.transitions.detach()[
              :, tag_dictionary.get_idx_for_item(STOP_TAG)
          ] = -10000
      self.to(flair.device)
  
imports: import torch
  import flair
label_desc: Use image node_id 1 to create a new CRF object from inherited base classes: torch.nn with example: obj = CRF(tag_dictionary, tagset_size, init_from_state_dict)