class_docstr: Transformer decoder consisting of *args.decoder_layers* layers. Each layer
  is a :class:`TransformerDecoderLayer`.
  
  Args:
      args (argparse.Namespace): parsed command-line arguments
      dictionary (~fairseq.data.Dictionary): decoding dictionary
      embed_tokens (torch.nn.Embedding): output embedding
      no_encoder_attn (bool, optional): whether to attend to encoder outputs
          (default: False).
class_docstr_tok: ["Transformer","decoder","consisting","of","*","args.decoder_layers","*","layers",".","Each","layer","is","a",":","class",":","`","TransformerDecoderLayer","`",".","Args",":","args","(","argparse.Namespace",")",":","parsed","command-line","arguments","dictionary","(","~fairseq.data.Dictionary",")",":","decoding","dictionary","embed_tokens","(","torch.nn.Embedding",")",":","output","embedding","no_encoder_attn","(","bool",",","optional",")",":","whether","to","attend","to","encoder","outputs","(","default",":","False",")","."]
docstr: 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
docstr_tok: ["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"]
code: def extract_features(
      self,
      prev_output_tokens,
      encoder_out: Optional[Dict[str, List[Tensor]]],
      incremental_state: Optional[
          Dict[str, Dict[str, Optional[Tensor]]]
      ] = None,
      full_context_alignment: bool = False,  # unused
      alignment_layer: Optional[int] = None,  # unused
      alignment_heads: Optional[int] = None,  # unsed
  ):
      """
      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
      """
      # incremental_state = None
      assert encoder_out is not None
      (x, encoder_outs, encoder_padding_mask) = self.pre_attention(
          prev_output_tokens, encoder_out, incremental_state
      )
      attn = None
      inner_states = [x]
      attn_list: List[Optional[Dict[str, Tensor]]] = []
  
      p_choose = torch.tensor([1.0])
  
      for i, layer in enumerate(self.layers):
          x, attn, _ = layer(
              x=x,
              encoder_out=encoder_outs,
              encoder_padding_mask=encoder_padding_mask,
              incremental_state=incremental_state,
              self_attn_mask=self.buffered_future_mask(x)
              if incremental_state is None
              else None,
          )
  
          inner_states.append(x)
          attn_list.append(attn)
  
          if incremental_state is not None:
              if_online = incremental_state["online"]["only"]
              assert if_online is not None
              if if_online.to(torch.bool):
                  # Online indicates that the encoder states are still changing
                  assert attn is not None
                  if self.policy_criterion == "any":
                      # Any head decide to read than read
                      head_read = (
                          layer.encoder_attn._get_monotonic_buffer(
                              incremental_state
                          )["head_read"]
                      )
                      assert head_read is not None
                      if head_read.any():
                          # We need to prune the last self_attn saved_state
                          # if model decide not to read
                          # otherwise there will be duplicated saved_state
                          self.clean_cache(incremental_state, i + 1)
  
                          return x, TransformerMonotonicDecoderOut(
                              action=0,
                              p_choose=p_choose,
                              attn_list=None,
                              encoder_out=None,
                              encoder_padding_mask=None,
                          )
  
      x = self.post_attention(x)
  
      return x, TransformerMonotonicDecoderOut(
          action=1,
          p_choose=p_choose,
          attn_list=attn_list,
          encoder_out=encoder_out,
          encoder_padding_mask=encoder_padding_mask,
      )
  
imports: from typing import Dict, List, NamedTuple, Optional
  import torch
  import torch.nn
  from examples.simultaneous_translation.modules.monotonic_transformer_layer import TransformerMonotonicDecoderLayer, TransformerMonotonicEncoderLayer
  from fairseq.models import register_model, register_model_architecture
  from fairseq.models.transformer import TransformerModel, TransformerEncoder, TransformerDecoder, base_architecture, transformer_iwslt_de_en, transformer_vaswani_wmt_en_de_big, tiny_architecture
  from torch import Tensor
label_desc: Use image node_id 6 for calling the TransformerMonotonicDecoder obj's underlying member method code with example usage: obj.extract_features(prev_output_tokens, encoder_out, incremental_state, full_context_alignment, alignment_layer, alignment_heads) and returns: x,  TransformerMonotonicDecoderOut, x,  TransformerMonotonicDecoderOut