class_docstr: Multilingual decoder.
class_docstr_tok: ["Multilingual","decoder","."]
docstr: Reorder buffered internal state (for incremental generation).
docstr_tok: ["Reorder","buffered","internal","state","(","for","incremental","generation",")","."]
code: def reorder_incremental_state(self, incremental_state, new_order):
      """Reorder buffered internal state (for incremental generation)."""
      if not incremental_state:
          return
      bsz = new_order.size(0)
      for lang_id, decoder in enumerate(self.decoders):
          if decoder is None:
              continue
          indices = torch.nonzero(
              incremental_state["lang_ids"] == lang_id
          )
          lang_bsz = indices.size(0)
          if lang_bsz > 0:
              if lang_bsz == bsz:
                  lang_new_order = new_order
              else:
                  lang_new_order = utils.densify(
                      new_order[indices.squeeze(1)]
                  )
              decoder.reorder_incremental_state(
                  incremental_state[lang_id], lang_new_order
              )
  
imports: import torch
  import torch.nn
  from fairseq.models import FairseqEncoder, FairseqIncrementalDecoder
  from pytorch_translate import utils
  from pytorch_translate.data import data
label_desc: Use image node_id 3 for calling the MultilingualDecoder obj's underlying member method code with example usage: obj.reorder_incremental_state(incremental_state, new_order) without return types