class_docstr: Wrap T5 in ParlAI.
class_docstr_tok: ["Wrap","T5","in","ParlAI","."]
code: def __init__(self, opt, dictionary):
      self.pad_idx = dictionary[dictionary.null_token]
      self.start_idx = self.pad_idx
      self.end_idx = dictionary[dictionary.end_token]
      super().__init__(self.pad_idx, self.start_idx, self.end_idx)
      self.t5 = build_t5(opt)
      self.encoder = ParlaiT5Encoder(
          opt, self.t5.get_encoder(), self.pad_idx
      )
      self.decoder = ParlaiT5Decoder(
          opt, self.t5.get_decoder(), self.pad_idx
      )
      self.paralleled = not opt["t5_model_parallel"]
  
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 1 to create a new ParlaiT5Model object from inherited base classes: TorchGeneratorModel with example: obj = ParlaiT5Model(opt, dictionary)