class_docstr: Dynamic CRF layer is used to approximate the traditional
  Conditional Random Fields (CRF)
  $P(y | x) = 1/Z(x) exp(sum_i s(y_i, x) + sum_i t(y_{i-1}, y_i, x))$
  
  where in this function, we assume the emition scores (s) are given,
  and the transition score is a |V| x |V| matrix $M$
  
  in the following two aspects:
   (1) it used a low-rank approximation for the transition matrix:
       $M = E_1 E_2^T$
   (2) it used a beam to estimate the normalizing factor Z(x)
class_docstr_tok: ["Dynamic","CRF","layer","is","used","to","approximate","the","traditional","Conditional","Random","Fields","(","CRF",")","$","P","(","y","|","x",")","=","1\/Z","(","x",")","exp","(","sum_i","s","(","y_i",",","x",")","+","sum_i","t","(","y_","{","i-1","}",",","y_i",",","x",")",")","$","where","in","this","function",",","we","assume","the","emition","scores","(","s",")","are","given",",","and","the","transition","score","is","a","|V|","x","|V|","matrix","$","M","$","in","the","following","two","aspects",":","(","1",")","it","used","a","low-rank","approximation","for","the","transition","matrix",":","$","M","=","E_1","E_2^T","$","(","2",")","it","used","a","beam","to","estimate","the","normalizing","factor","Z","(","x",")"]
code: def __init__(self, num_embedding, low_rank=32, beam_size=64):
      super().__init__()
  
      self.E1 = nn.Embedding(num_embedding, low_rank)
      self.E2 = nn.Embedding(num_embedding, low_rank)
  
      self.vocb = num_embedding
      self.rank = low_rank
      self.beam = beam_size
  
file_path: fairseq/fairseq/modules/dynamic_crf_layer.py
imports: import numpy
  import torch
  import torch.nn
label_desc: Use image node_id 1 to create a new DynamicCRF object from inherited base classes: nn with example: obj = DynamicCRF(num_embedding, low_rank, beam_size)