class_docstr: Sequence to sequence parent module.
docstr: Reorder encoder states according to a new set of indices.
docstr_tok: ["Reorder","encoder","states","according","to","a","new","set","of","indices","."]
code: def reorder_encoder_states(self, encoder_states, indices):
      """
      Reorder encoder states according to a new set of indices.
      """
      enc_out, hidden, attn_mask = encoder_states
  
      # make sure we swap the hidden state around, apropos multigpu settings
      hidden = _transpose_hidden_state(hidden)
  
      # LSTM or GRU/RNN hidden state?
      if isinstance(hidden, torch.Tensor):
          hid, cell = hidden, None
      else:
          hid, cell = hidden
  
      if not torch.is_tensor(indices):
          # cast indices to a tensor if needed
          indices = torch.LongTensor(indices).to(hid.device)
  
      hid = hid.index_select(1, indices)
      if cell is None:
          hidden = hid
      else:
          cell = cell.index_select(1, indices)
          hidden = (hid, cell)
  
      if self.attn_type != "none":
          enc_out = enc_out.index_select(0, indices)
          attn_mask = attn_mask.index_select(0, indices)
  
      # and bring it back to multigpu friendliness
      hidden = _transpose_hidden_state(hidden)
  
      return enc_out, hidden, attn_mask
  
imports: import math
  import torch
  import torch.nn
  from torch.nn.parameter import Parameter
  from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence
  import torch.nn.functional
  from parlai.utils.torch import neginf
  from parlai.core.torch_generator_agent import TorchGeneratorModel
label_desc: Use image node_id 2 for calling the Seq2seq obj's underlying member method code with example usage: obj.reorder_encoder_states(encoder_states, indices) and returns: enc_out,  hidden,  attn_mask