class_docstr: A complete encoder-decoder model, with optional attention.
  
  A parent class which makes use of the contextual_embedding (such as a charlm)
  can make use of unsaved_modules when saving.
class_docstr_tok: ["A","complete","encoder-decoder","model",",","with","optional","attention",".","A","parent","class","which","makes","use","of","the","contextual_embedding","(","such","as","a","charlm",")","can","make","use","of","unsaved_modules","when","saving","."]
docstr: Encode source sequence. 
docstr_tok: ["Encode","source","sequence","."]
code: def encode(self, enc_inputs, lens):
      """Encode source sequence."""
      h0, c0 = self.zero_state(enc_inputs)
  
      packed_inputs = nn.utils.rnn.pack_padded_sequence(
          enc_inputs, lens, batch_first=True
      )
      packed_h_in, (hn, cn) = self.encoder(packed_inputs, (h0, c0))
      h_in, _ = nn.utils.rnn.pad_packed_sequence(
          packed_h_in, batch_first=True
      )
      hn = torch.cat((hn[-1], hn[-2]), 1)
      cn = torch.cat((cn[-1], cn[-2]), 1)
      return h_in, (hn, cn)
  
imports: import logging
  import torch
  from torch import nn
  import torch.nn.functional
  import numpy
  import stanza.models.common.seq2seq_constant
  from stanza.models.common import utils
  from stanza.models.common.seq2seq_modules import LSTMAttention
  from stanza.models.common.beam import Beam
label_desc: Use image node_id 5 for calling the Seq2SeqModel obj's underlying member method code with example usage: obj.encode(enc_inputs, lens) and returns: h_in,  hn,  cn