(self, tgt, memory_bank, state, memory_lengths=None,
                step=None,sent_encoder=None,src_sents=None)
return decoder_outputs, state, attns
Args:
            tgt (`LongTensor`): sequences of padded tokens
                 `[tgt_len x batch x nfeats]`.
            memory_bank (`FloatTensor`): vectors from the encoder
                 `[src_len x batch x hidden]`.
            state (:obj:`onmt.models.DecoderState`):
                 decoder state object to initialize the decoder
            memory_lengths (`LongTensor`): the padded source lengths
                `[batch]`.
        Returns:
            (`FloatTensor`,:obj:`onmt.Models.DecoderState`,`FloatTensor`):
                * decoder_outputs: output from the decoder (after attn)
                         `[tgt_len x batch x hidden]`.
                * decoder_state: final hidden state from the decoder
                * attns: distribution over src at each tgt
                        `[tgt_len x batch x src_len]`.
Args:
            tgt (`LongTensor`): sequences of padded tokens
                 `[tgt_len x batch x nfeats]`.
            memory_bank (`FloatTensor`): vectors from the encoder
                 `[src_len x batch x hidden]`.
            state (:obj:`onmt.models.DecoderState`):
                 decoder state object to initialize the decoder
            memory_lengths (`LongTensor`): the padded source lengths
                `[batch]`.
        Returns:
            (`FloatTensor`,:obj:`onmt.Models.DecoderState`,`FloatTensor`):
                * decoder_outputs: output from the decoder (after attn)
                         `[tgt_len x batch x hidden]`.
                * decoder_state: final hidden state from the decoder
                * attns: distribution over src at each tgt
                        `[tgt_len x batch x src_len]`.
Args : tgt ( LongTensor ) : sequences of padded tokens [ tgt_len x batch x nfeats ] . memory_bank ( FloatTensor ) : vectors from the encoder [ src_len x batch x hidden ] . state ( : obj : onmt . models . DecoderState ) : decoder state object to initialize the decoder memory_lengths ( LongTensor ) : the padded source lengths [ batch ] . Returns : ( FloatTensor : obj : onmt . Models . DecoderState FloatTensor ) : * decoder_outputs : output from the decoder ( after attn ) [ tgt_len x batch x hidden ] . * decoder_state : final hidden state from the decoder * attns : distribution over src at each tgt [ tgt_len x batch x src_len ] .
def forward(self, tgt, memory_bank, state, memory_lengths=None,
                step=None,sent_encoder=None,src_sents=None):
        """
        Args:
            tgt (`LongTensor`): sequences of padded tokens
                 `[tgt_len x batch x nfeats]`.
            memory_bank (`FloatTensor`): vectors from the encoder
                 `[src_len x batch x hidden]`.
            state (:obj:`onmt.models.DecoderState`):
                 decoder state object to initialize the decoder
            memory_lengths (`LongTensor`): the padded source lengths
                `[batch]`.
        Returns:
            (`FloatTensor`,:obj:`onmt.Models.DecoderState`,`FloatTensor`):
                * decoder_outputs: output from the decoder (after attn)
                         `[tgt_len x batch x hidden]`.
                * decoder_state: final hidden state from the decoder
                * attns: distribution over src at each tgt
                        `[tgt_len x batch x src_len]`.
        """
        # Check
        assert isinstance(state, RNNDecoderState)
        # tgt.size() returns tgt length and batch
        _, tgt_batch, _ = tgt.size()
        _, memory_batch, _ = memory_bank.size()
        aeq(tgt_batch, memory_batch)
        # END


        # 23333: TODO I changed this return value 'sent_decoder'


        # Run the forward pass of the RNN.
        decoder_final, decoder_outputs, attns = self._run_forward_pass(
            tgt, memory_bank, state, memory_lengths=memory_lengths,sent_encoder=sent_encoder,src_sents=src_sents)

        # Update the state with the result.
        final_output = decoder_outputs[-1]
        coverage = None
        if "coverage" in attns:
            coverage = attns["coverage"][-1].unsqueeze(0)
        state.update_state(decoder_final, final_output.unsqueeze(0), coverage)

        # Concatenates sequence of tensors along a new dimension.
        # NOTE: v0.3 to 0.4: decoder_outputs / attns[*] may not be list
        #       (in particular in case of SRU) it was not raising error in 0.3
        #       since stack(Variable) was allowed.
        #       In 0.4, SRU returns a tensor that shouldn't be stacke
        if type(decoder_outputs) == list:
            decoder_outputs = torch.stack(decoder_outputs)

            for k in attns:
                if type(attns[k]) == list:
                    attns[k] = torch.stack(attns[k])

        return decoder_outputs, state, attns
def forward ( self , tgt , memory_bank , state , memory_lengths = None , step = None , sent_encoder = None , src_sents = None ) : # Check assert isinstance ( state , RNNDecoderState ) # tgt.size() returns tgt length and batch _ , tgt_batch , _ = tgt . size ( ) _ , memory_batch , _ = memory_bank . size ( ) aeq ( tgt_batch , memory_batch ) # END # 23333: TODO I changed this return value 'sent_decoder' # Run the forward pass of the RNN. decoder_final , decoder_outputs , attns = self . _run_forward_pass ( tgt , memory_bank , state , memory_lengths = memory_lengths , sent_encoder = sent_encoder , src_sents = src_sents ) # Update the state with the result. final_output = decoder_outputs [ - 1 ] coverage = None if "coverage" in attns : coverage = attns [ "coverage" ] [ - 1 ] . unsqueeze ( 0 ) state . update_state ( decoder_final , final_output . unsqueeze ( 0 ) , coverage ) # Concatenates sequence of tensors along a new dimension. # NOTE: v0.3 to 0.4: decoder_outputs / attns[*] may not be list #       (in particular in case of SRU) it was not raising error in 0.3 #       since stack(Variable) was allowed. #       In 0.4, SRU returns a tensor that shouldn't be stacke if type ( decoder_outputs ) == list : decoder_outputs = torch . stack ( decoder_outputs ) for k in attns : if type ( attns [ k ] ) == list : attns [ k ] = torch . stack ( attns [ k ] ) return decoder_outputs , state , attns