class_docstr: BART Model.
docstr: Incremental state is weird to handle when we seed decoder with two inputs
  initially.
docstr_tok: ["Incremental","state","is","weird","to","handle","when","we","seed","decoder","with","two","inputs","initially","."]
code: def reorder_decoder_incremental_state(
      self,
      incremental_state: Dict[str, Any],
      inds: Union[List[int], torch.LongTensor],
  ) -> Optional[Dict[str, Any]]:
      """
      Incremental state is weird to handle when we seed decoder with two inputs
      initially.
      """
      # we only have this method called when it's actually being used
      assert incremental_state is not None
      assert len(incremental_state) > 0
  
      for incr_state_l in incremental_state.values():
          assert "self_attn" in incr_state_l
          assert "prev_mask" in incr_state_l["self_attn"]
          self_attn_mask = incr_state_l["self_attn"]["prev_mask"]
          # check this is on the very first run with incremental state
          if self_attn_mask.ndim == 3 and tuple(
              self_attn_mask.shape[1:]
          ) == (2, 2):
              # cut off the inappropriate incremental state
              incr_state_l["self_attn"]["prev_mask"] = self_attn_mask[
                  :, -1:, :
              ]
  
      return super().reorder_decoder_incremental_state(
          incremental_state, inds
      )
  
file_path: ParlAI/parlai/agents/bart/modules.py
imports: import torch
  import torch.nn.functional
  from typing import Any, Dict, Union, List, Optional
  from parlai.agents.transformer.modules import TransformerGeneratorModel
label_desc: Use image node_id 3 for calling the BartModel obj's underlying member method code with example usage: obj.reorder_decoder_incremental_state(incremental_state, inds) and returns: super