class_docstr: Override TransformerMemNetModel to build DPR Model Components.
class_docstr_tok: ["Override","TransformerMemNetModel","to","build","DPR","Model","Components","."]
code: def build_candidate_encoder(
      cls,
      opt: Opt,
      dictionary: DictionaryAgent,
      embedding: Optional[torch.nn.Embedding] = None,
      padding_idx: Optional[int] = None,
      reduction_type: str = "mean",
  ):
      _, _, document_model, document_path = cls._get_build_options(opt)
      return DprDocumentEncoder(
          opt, dpr_model=document_model, pretrained_path=document_path
      )
  
imports: from parlai.agents.transformer.transformer import TransformerRankerAgent
  from parlai.agents.transformer.modules import TransformerMemNetModel, TransformerEncoder
  from parlai.agents.hugging_face.dict import HuggingFaceDictionaryAgent
  from parlai.agents.rag.args import DPR_ZOO_MODEL
  from parlai.agents.rag.conversion_utils import BertConversionUtils
  from parlai.core.build_data import modelzoo_path
  from parlai.core.dict import DictionaryAgent
  from parlai.core.loader import register_agent
  from parlai.core.opt import Opt
  from parlai.core.torch_ranker_agent import TorchRankerAgent
  from parlai.utils.io import PathManager
  import parlai.utils.logging
  import os
  import torch
  import torch.cuda
  import torch.nn
  from transformers import BertConfig
  from typing import Dict, Optional
label_desc: Use image node_id 3 for calling the DPRModel obj's underlying member method code with example usage: obj.build_candidate_encoder(cls, opt, dictionary, embedding, padding_idx, reduction_type) and returns: DprDocumentEncoder