class_docstr: Subclass TransformerEncoder to use additional positions if desired.
docstr: RagEncoder initialization.
  
  The Rag Seq2seq encoder is just a regular encoder
docstr_tok: ["RagEncoder","initialization",".","The","Rag","Seq2seq","encoder","is","just","a","regular","encoder"]
code: def __init__(
      self,
      opt: Opt,
      dictionary: DictionaryAgent,
      embedding: Optional[torch.nn.Embedding] = None,
      padding_idx: int = 0,
  ):
      """
      RagEncoder initialization.
  
      The Rag Seq2seq encoder is just a regular encoder
      """
      n_init_positions = (
          get_n_positions_from_options(opt) + opt["n_extra_positions"]
      )
      super().__init__(
          opt=opt,
          vocabulary_size=len(dictionary),
          embedding=embedding,
          padding_idx=padding_idx,
          reduction_type="none",
          n_positions=n_init_positions,
      )
  
imports: import torch
  import torch.cuda
  import torch.nn
  import torch.nn.functional
  from typing import Any, Tuple, Dict, Optional, List, Union, Type
  from parlai.agents.hugging_face.t5 import ParlaiT5Encoder, ParlaiT5Decoder, build_t5, set_device
  from parlai.agents.transformer.modules import TransformerEncoder, TransformerDecoder, get_n_positions_from_options, create_embeddings
  from parlai.core.dict import DictionaryAgent
  from parlai.core.opt import Opt
  from parlai.core.torch_generator_agent import TorchGeneratorModel
  from parlai.utils.torch import padded_tensor
  from parlai.agents.rag.retrievers import RagRetriever, retriever_factory, Document
label_desc: Use image node_id 1 to create a new RagEncoder object from inherited base classes: TransformerEncoder with example: obj = RagEncoder(opt, dictionary, embedding, padding_idx)