class_docstr: Decoder with general structure of Chen et al., The Best of Both Worlds:
  Combining Recent Advances in Neural Machine Translation, 2018.
  https://arxiv.org/abs/1804.09849
class_docstr_tok: ["Decoder","with","general","structure","of","Chen","et","al.",",","The","Best","of","Both","Worlds",":","Combining","Recent","Advances","in","Neural","Machine","Translation",",","2018.","https",":","\/\/arxiv.org\/abs\/1804.09849"]
code: def reorder_incremental_state(self, incremental_state, new_order):
      # parent reorders attention model
      super().reorder_incremental_state(incremental_state, new_order)
  
      cached_state = utils.get_incremental_state(
          self, incremental_state, "cached_state"
      )
      if cached_state is None:
          return
  
      # Last 2 elements of prev_states are encoder projections
      # used for ONNX export
      for i, state in enumerate(cached_state[:-2]):
          cached_state[i] = state.index_select(1, new_order)
  
      utils.set_incremental_state(
          self, incremental_state, "cached_state", cached_state
      )
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from fairseq import utils
  from fairseq.models import FairseqEncoderDecoderModel, FairseqIncrementalDecoder, register_model, register_model_architecture, transformer
  from fairseq.modules import MultiheadAttention
  from pytorch_translate import multilingual_model, transformer, vocab_reduction
  from pytorch_translate.utils import torch_find
label_desc: Use image node_id 13 for calling the HybridRNNDecoder obj's underlying member method code with example usage: obj.reorder_incremental_state(incremental_state, new_order) without return types