class_docstr: LSTM decoder.
code: def reorder_incremental_state(
      self,
      incremental_state: Dict[str, Dict[str, Optional[Tensor]]],
      new_order: Tensor,
  ):
      if incremental_state is None or len(incremental_state) == 0:
          return
      prev_hiddens, prev_cells, input_feed = self.get_cached_state(
          incremental_state
      )
      prev_hiddens = [
          p.index_select(0, new_order) for p in prev_hiddens
      ]
      prev_cells = [p.index_select(0, new_order) for p in prev_cells]
      if input_feed is not None:
          input_feed = input_feed.index_select(0, new_order)
      cached_state_new = torch.jit.annotate(
          Dict[str, Optional[Tensor]],
          {
              "prev_hiddens": torch.stack(prev_hiddens),
              "prev_cells": torch.stack(prev_cells),
              "input_feed": input_feed,
          },
      )
      self.set_incremental_state(
          incremental_state, "cached_state", cached_state_new
      ),
      return
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq import utils
  from fairseq.models import FairseqEncoder, FairseqEncoderDecoderModel, FairseqIncrementalDecoder, register_model, register_model_architecture
  from fairseq.modules import AdaptiveSoftmax, FairseqDropout
  from torch import Tensor
label_desc: Use image node_id 6 for calling the LSTMDecoder obj's underlying member method code with example usage: obj.reorder_incremental_state(incremental_state, new_order) without return types