    def extract_features_scriptable(
        self,
        prev_output_tokens: Dict[str, Tensor],
        encoder_out: Optional[Dict[str, List[Tensor]]],
        incremental_state: Optional[
            List[Dict[str, Dict[str, Optional[Tensor]]]]
        ] = None,
        full_context_alignment: bool = False,
        alignment_layer: Optional[int] = None,
        alignment_heads: Optional[int] = None,
    ):
        """
        The core function of *forward* but only return features.

        The input (prev_output_tokens) is a dictionary over all channels,
        expected to have the following form:
            {
                'channel1' : Tensor((batch x tgt_len)),
                'channel2' : Tensor((batch x tgt_len)),
            }

        Args:
            full_context_alignment (bool, optional): don't apply
                auto-regressive mask to self-attention (default: False).
            alignment_layer (int, optional): return mean alignment over
                heads at this layer (default: last layer).
            alignment_heads (int, optional): only average alignment over
                this many heads (default: all heads).

        Returns:
            tuple:
                - the decoder's features, dict over channels of tensors
                    of shape `(batch, tgt_len, embed_dim)`
                - a dictionary with any model-specific outputs
        """
        if alignment_layer is None:
            alignment_layer = self.num_layers - 1

        x_list = []
        for i, channel in enumerate(self.channels):
            # embed positions
            positions = None
            if self.embed_positions is not None:
                positions = self.embed_positions(
                    prev_output_tokens[channel],
                    incremental_state=incremental_state[i]
                    if incremental_state is not None
                    else None,
                )

            if incremental_state is not None:
                prev_output_tokens[channel] = prev_output_tokens[channel][:, -1:]
                if positions is not None:
                    positions = positions[:, -1:]

            # embed tokens and positions
            x = self.embed_tokens(prev_output_tokens[channel])

            if self.project_in_dim is not None:
                x = self.project_in_dim(x)

            x = self.embed_scale * x

            if self.quant_noise is not None:
                x = self.quant_noise(x)

            if positions is not None:
                x += positions

            if self.layernorm_embedding is not None:
                x = self.layernorm_embedding(x)

            x = self.dropout_module(x)

            # B x T x C -> T x B x C
            x = x.transpose(0, 1)

            x_list.append(x)

        self_attn_padding_mask: Optional[Tensor] = None
        if (
            self.cross_self_attention
            or prev_output_tokens[self.channels[0]].eq(self.padding_idx).any()
        ):
            self_attn_padding_mask = prev_output_tokens[self.channels[0]].eq(
                self.padding_idx
            )

        # decoder layers
        attn: Optional[Dict[Tensor]] = None
        inner_states: List[Optional[Dict[str, Tensor]]] = [
            {channel: x_list[i] for i, channel in enumerate(self.channels)}
        ]
        for idx, layer in enumerate(self.layers):
            if incremental_state is None and not full_context_alignment:
                self_attn_mask = self.buffered_future_mask(x_list[0])
            else:
                self_attn_mask = None

            # need to change to tensor for the checkpoint activation to work
            if isinstance(x_list, list):
                x_list = torch.stack(x_list)
            x_list, layer_attn_list, _ = layer(
                x_list,
                encoder_out["encoder_out"][0]
                if (encoder_out is not None and len(encoder_out["encoder_out"]) > 0)
                else None,
                encoder_out["encoder_padding_mask"][0]
                if (
                    encoder_out is not None
                    and len(encoder_out["encoder_padding_mask"]) > 0
                )
                else None,
                incremental_state,
                self_attn_mask=self_attn_mask,
                self_attn_padding_mask=self_attn_padding_mask,
                need_attn=bool((idx == alignment_layer)),
                need_head_weights=bool((idx == alignment_layer)),
            )

            inner_states.append(
                {channel: x_list[i] for i, channel in enumerate(self.channels)}
            )
            if idx == alignment_layer and all(
                layer_attn is not None for layer_attn in layer_attn_list
            ):
                attn = {
                    channel: layer_attn_list[i].float().to(x_list[0])
                    for i, channel in enumerate(self.channels)
                }
        # change back from tensor to list
        if not isinstance(x_list, list):
            x_list = list(torch.unbind(x_list))

        if attn is not None:
            for channel in attn:
                if alignment_heads is not None:
                    attn[channel] = attn[channel][:alignment_heads]

                # average probabilities over heads
                attn[channel] = attn[channel].mean(dim=0)

        for i, x in enumerate(x_list):
            if self.layer_norm is not None:
                x = self.layer_norm(x)

            # T x B x C -> B x T x C
            x = x.transpose(0, 1)

            if self.project_out_dim is not None:
                x = self.project_out_dim(x)

            x_list[i] = x

        x = {channel: x_list[i] for i, channel in enumerate(self.channels)}

        return x, {"attn": [attn], "inner_states": inner_states}
The core function of *forward* but only return features.

The input (prev_output_tokens) is a dictionary over all channels,
expected to have the following form:
{
'channel1' : Tensor((batch x tgt_len)),
'channel2' : Tensor((batch x tgt_len)),
}

Args:
full_context_alignment (bool, optional): don't apply
auto-regressive mask to self-attention (default: False).
alignment_layer (int, optional): return mean alignment over
heads at this layer (default: last layer).
alignment_heads (int, optional): only average alignment over
this many heads (default: all heads).

Returns:
tuple:
- the decoder's features, dict over channels of tensors
of shape `(batch, tgt_len, embed_dim)`
- a dictionary with any model-specific outputs
fairseq/models/speech_dlm/modules/speech_dlm_decoder.py