class_docstr: An implementation of pointer-generator networks
  :cite:`DBLP:journals/corr/SeeLM17`.
  
  These networks consider copying words
  directly from the source sequence.
  
  The copy generator is an extended version of the standard
  generator that computes three values.
  
  * :math:`p_{softmax}` the standard softmax over `tgt_dict`
  * :math:`p(z)` the probability of copying a word from
    the source
  * :math:`p_{copy}` the probility of copying a particular word.
    taken from the attention distribution directly.
  
  The model returns a distribution over the extend dictionary,
  computed as
  
  :math:`p(w) = p(z=1)  p_{copy}(w)  +  p(z=0)  p_{softmax}(w)`
  
  Args:
     input_size (int): size of input representation
     output_size (int): size of output vocabulary
     pad_idx (int)
class_docstr_tok: ["An","implementation","of","pointer-generator","networks",":","cite",":","`","DBLP",":","journals\/corr\/SeeLM17","`",".","These","networks","consider","copying","words","directly","from","the","source","sequence",".","The","copy","generator","is","an","extended","version","of","the","standard","generator","that","computes","three","values",".","*",":","math",":","`","p_","{","softmax","}","`","the","standard","softmax","over","`","tgt_dict","`","*",":","math",":","`","p","(","z",")","`","the","probability","of","copying","a","word","from","the","source","*",":","math",":","`","p_","{","copy","}","`","the","probility","of","copying","a","particular","word",".","taken","from","the","attention","distribution","directly",".","The","model","returns","a","distribution","over","the","extend","dictionary",",","computed","as",":","math",":","`","p","(","w",")","=","p","(","z=1",")","p_","{","copy","}","(","w",")","+","p","(","z=0",")","p_","{","softmax","}","(","w",")","`","Args",":","input_size","(","int",")",":","size","of","input","representation","output_size","(","int",")",":","size","of","output","vocabulary","pad_idx","(","int",")"]
code: def __init__(self, input_size, output_size, pad_idx):
      super(CopyGenerator, self).__init__()
      self.linear = nn.Linear(input_size, output_size)
      self.linear_copy = nn.Linear(input_size, 1)
      self.pad_idx = pad_idx
  
file_path: OpenNMT-py/onmt/modules/copy_generator.py
imports: import torch
  import torch.nn
label_desc: Use image node_id 1 to create a new CopyGenerator object from inherited base classes: nn with example: obj = CopyGenerator(input_size, output_size, pad_idx)