(self, src, lengths=None)
return encoder_final, memory_bank
See :obj:`EncoderBase.forward()`
See :obj:`EncoderBase.forward()`
See : obj : EncoderBase . forward ()
def forward(self, src, lengths=None):
        "See :obj:`EncoderBase.forward()`"
        self._check_args(src, lengths)

        emb = self.embeddings(src)
        # s_len, batch, emb_dim = emb.size()

        packed_emb = emb
        if lengths is not None and not self.no_pack_padded_seq:
            # Lengths data is wrapped inside a Tensor.
            lengths = lengths.view(-1).tolist()
            packed_emb = pack(emb, lengths)

        memory_bank, encoder_final = self.rnn(packed_emb)

        if lengths is not None and not self.no_pack_padded_seq:
            memory_bank = unpack(memory_bank)[0]

        if self.use_bridge:
            encoder_final = self._bridge(encoder_final)
        return encoder_final, memory_bank
def forward ( self , src , lengths = None ) : self . _check_args ( src , lengths ) emb = self . embeddings ( src ) # s_len, batch, emb_dim = emb.size() packed_emb = emb if lengths is not None and not self . no_pack_padded_seq : # Lengths data is wrapped inside a Tensor. lengths = lengths . view ( - 1 ) . tolist ( ) packed_emb = pack ( emb , lengths ) memory_bank , encoder_final = self . rnn ( packed_emb ) if lengths is not None and not self . no_pack_padded_seq : memory_bank = unpack ( memory_bank ) [ 0 ] if self . use_bridge : encoder_final = self . _bridge ( encoder_final ) return encoder_final , memory_bank