class_docstr: NMTModel Class
  See :class:`~onmt.models.BaseModel` for options.
class_docstr_tok: ["NMTModel","Class","See",":","class",":","`","~onmt.models.BaseModel","`","for","options","."]
docstr: An NMTModel forward the src side to the encoder.
  Then the output of encoder ``enc_out`` is forwarded to the
  decoder along with the target excluding the last token.
  The decoder state is initiliazed with:
  * enc_final_hs in the case of RNNs
  * enc_out + enc_final_hs in the case of CNNs
  * src in the case of Transformer
docstr_tok: ["An","NMTModel","forward","the","src","side","to","the","encoder",".","Then","the","output","of","encoder","``","enc_out","``","is","forwarded","to","the","decoder","along","with","the","target","excluding","the","last","token",".","The","decoder","state","is","initiliazed","with",":","*","enc_final_hs","in","the","case","of","RNNs","*","enc_out","+","enc_final_hs","in","the","case","of","CNNs","*","src","in","the","case","of","Transformer"]
code: def forward(self, src, tgt, src_len, bptt=False, with_align=False):
      """An NMTModel forward the src side to the encoder.
      Then the output of encoder ``enc_out`` is forwarded to the
      decoder along with the target excluding the last token.
      The decoder state is initiliazed with:
      * enc_final_hs in the case of RNNs
      * enc_out + enc_final_hs in the case of CNNs
      * src in the case of Transformer"""
  
      dec_in = tgt[:, :-1, :]
      enc_out, enc_final_hs, src_len = self.encoder(src, src_len)
      if not bptt:
          self.decoder.init_state(src, enc_out, enc_final_hs)
      dec_out, attns = self.decoder(
          dec_in, enc_out, src_len=src_len, with_align=with_align
      )
      return dec_out, attns
  
imports: import torch
  import torch.nn
  from glob import glob
label_desc: Use image node_id 2 for calling the NMTModel obj's underlying member method code with example usage: obj.forward(src, tgt, src_len, bptt, with_align) and returns: dec_out,  attns