Args: prev_output_tokens (LongTensor): shifted output tokens of shape `(batch, tgt_len)`, for teacher forcing encoder_out (dict, optional): output from the encoder, used for encoder-side attention Returns: tuple:
(self, prev_output_tokens, encoder_out=None, **kwargs)
| 21 | |
| 22 | |
| 23 | def forward(self, prev_output_tokens, encoder_out=None, **kwargs): |
| 24 | """ |
| 25 | Args: |
| 26 | prev_output_tokens (LongTensor): shifted output tokens of shape |
| 27 | `(batch, tgt_len)`, for teacher forcing |
| 28 | encoder_out (dict, optional): output from the encoder, used for |
| 29 | encoder-side attention |
| 30 | |
| 31 | Returns: |
| 32 | tuple: |
| 33 | - the decoder's output of shape `(batch, tgt_len, vocab)` |
| 34 | - a dictionary with any model-specific outputs |
| 35 | """ |
| 36 | x, extra = self.extract_features( |
| 37 | prev_output_tokens, encoder_out=encoder_out, **kwargs |
| 38 | ) |
| 39 | x = self.output_layer(x) |
| 40 | return x, extra |
| 41 | |
| 42 | def extract_features(self, prev_output_tokens, encoder_out=None, **kwargs): |
| 43 | """ |
nothing calls this directly
no test coverage detected