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: Clean cache in the monotonic layers.
  The cache is generated because of a forward pass of decoder has run but no prediction,
  so that the self attention key value in decoder is written in the incremental state.
  end_id is the last idx of the layers
docstr_tok: ["Clean","cache","in","the","monotonic","layers",".","The","cache","is","generated","because","of","a","forward","pass","of","decoder","has","run","but","no","prediction",",","so","that","the","self","attention","key","value","in","decoder","is","written","in","the","incremental","state",".","end_id","is","the","last","idx","of","the","layers"]
code: def clean_cache(
      self,
      incremental_state: Optional[
          Dict[str, Dict[str, Optional[Tensor]]]
      ],
      end_id: Optional[int] = None,
  ):
      """
      Clean cache in the monotonic layers.
      The cache is generated because of a forward pass of decoder has run but no prediction,
      so that the self attention key value in decoder is written in the incremental state.
      end_id is the last idx of the layers
      """
      if end_id is None:
          end_id = len(self.layers)
  
      for index, layer in enumerate(self.layers):
          if index < end_id:
              layer.prune_incremental_state(incremental_state)
  
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 5 for calling the TransformerMonotonicDecoder obj's underlying member method code with example usage: obj.clean_cache(incremental_state, end_id) without return types