class_docstr: Wrap T5 in ParlAI.
class_docstr_tok: ["Wrap","T5","in","ParlAI","."]
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)
      mask = torch.index_select(mask, 0, indices)
      return enc, mask
  
imports: import torch
  from typing import Optional, Dict, Any, Tuple
  from transformers import T5ForConditionalGeneration
  from parlai.agents.hugging_face.hugging_face import HF_VERSION
  from parlai.agents.hugging_face.dict import T5DictionaryAgent
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from parlai.core.torch_agent import Batch, TorchAgent
  from parlai.core.torch_generator_agent import TorchGeneratorAgent, TorchGeneratorModel
  from parlai.utils.fsdp import is_fsdp, delay_halving
label_desc: Use image node_id 3 for calling the ParlaiT5Model obj's underlying member method code with example usage: obj.reorder_encoder_states(encoder_states, indices) and returns: enc,  mask