def extract_features(self, prev_output_tokens, encoder_out=None, incremental_state=None, **unused):
    "\n        Similar to *forward* but only return features.\n\n        Returns:\n            tuple:\n                - the decoder's features of shape `(batch, tgt_len, embed_dim)`\n                - a dictionary with any model-specific outputs\n        "
    positions = (self.embed_positions(prev_output_tokens, incremental_state=incremental_state) if (self.embed_positions is not None) else None)
    if (incremental_state is not None):
        prev_output_tokens = prev_output_tokens[:, (- 1):]
        if (positions is not None):
            positions = positions[:, (- 1):]
    x = (self.embed_scale * self.embed_tokens(prev_output_tokens))
    if (self.project_in_dim is not None):
        x = self.project_in_dim(x)
    if (positions is not None):
        x += positions
    x = F.dropout(x, p=self.dropout, training=self.training)
    x = x.transpose(0, 1)
    attn = None
    inner_states = [x]
    for layer in self.layers:
        dropout_probability = np.random.random()
        if ((not self.training) or (dropout_probability > self.layerdrop)):
            (x, attn, _) = layer(x, (encoder_out['encoder_out'] if (encoder_out is not None) else None), (encoder_out['encoder_padding_mask'] if (encoder_out is not None) else None), incremental_state, self_attn_mask=(self.buffered_future_mask(x) if (incremental_state is None) else None))
            inner_states.append(x)
    if self.layer_norm:
        x = self.layer_norm(x)
    x = x.transpose(0, 1)
    return (x, {'attn': attn, 'inner_states': inner_states})
Similar to *forward* but only return features.

Returns:
    tuple:
        - the decoder's features of shape `(batch, tgt_len, embed_dim)`
        - a dictionary with any model-specific outputs
def extract_features(self, prev_output_tokens, encoder_out=None, incremental_state=None, **unused):
    "\n        Similar to *forward* but only return features.\n\n        Returns:\n            tuple:\n                - the decoder's features of shape `(batch, tgt_len, embed_dim)`\n                - a dictionary with any model-specific outputs\n        "
    positions = (self.embed_positions(prev_output_tokens, incremental_state=incremental_state) if (self.embed_positions is not None) else None)
    if (incremental_state is not None):
        prev_output_tokens = prev_output_tokens[:, (- 1):]
        if (positions is not None):
            positions = positions[:, (- 1):]
    x = (self.embed_scale * self.embed_tokens(prev_output_tokens))
    if (self.project_in_dim is not None):
        x = self.project_in_dim(x)
    if (positions is not None):
        x += positions
    x = F.dropout(x, p=self.dropout, training=self.training)
    x = x.transpose(0, 1)
    attn = None
    inner_states = [x]
    for layer in self.layers:
        dropout_probability = np.random.random()
        if ((not self.training) or (dropout_probability > self.layerdrop)):
            (x, attn, _) = layer(x, (encoder_out['encoder_out'] if (encoder_out is not None) else None), (encoder_out['encoder_padding_mask'] if (encoder_out is not None) else None), incremental_state, self_attn_mask=(self.buffered_future_mask(x) if (incremental_state is None) else None))
            inner_states.append(x)
    if self.layer_norm:
        x = self.layer_norm(x)
    x = x.transpose(0, 1)
    return (x, {'attn': attn, 'inner_states': inner_states})