class_docstr: Implements a full generator model, with one encoder and one decoder.
class_docstr_tok: ["Implements","a","full","generator","model",",","with","one","encoder","and","one","decoder","."]
docstr: Reorder the encoder states.
  
  See ``TorchGeneratorModel.reorder_encoder_states`` for a description.
docstr_tok: ["Reorder","the","encoder","states",".","See","``","TorchGeneratorModel.reorder_encoder_states","``","for","a","description","."]
code: def reorder_encoder_states(self, encoder_states, indices):
      """
      Reorder the encoder states.
  
      See ``TorchGeneratorModel.reorder_encoder_states`` for a description.
      """
      enc, mask = encoder_states
      if not torch.is_tensor(indices):
          indices = torch.LongTensor(indices).to(enc.device)
      enc = torch.index_select(enc, 0, indices)
      if mask is not None:
          mask = torch.index_select(mask, 0, indices)
      return enc, mask
  
file_path: ParlAI/parlai/agents/transformer/modules/generator.py
imports: from __future__ import annotations
  from typing import Dict, Type
  import torch
  import torch.cuda
  import torch.nn.functional
  from parlai.agents.transformer.modules import create_embeddings, TransformerDecoder, TransformerEncoder
  from parlai.agents.transformer.modules.modular import swappable
  from parlai.core.opt import Opt
  from parlai.core.torch_agent import DictionaryAgent
  from parlai.core.torch_generator_agent import TorchGeneratorModel
  from parlai.utils.torch import neginf
label_desc: Use image node_id 4 for calling the TransformerGeneratorModel obj's underlying member method code with example usage: obj.reorder_encoder_states(encoder_states, indices) and returns: enc,  mask