class_docstr: Basically provide a wrapper around TransformerEncoder to load DPR Query/Document
  models.
class_docstr_tok: ["Basically","provide","a","wrapper","around","TransformerEncoder","to","load","DPR","Query\/Document","models","."]
code: def __init__(
      self,
      opt: Opt,
      dpr_model: str = "bert",
      pretrained_path: str = DPR_ZOO_MODEL,
      encoder_type: str = "query",
  ):
      # Override options
      try:
          config: BertConfig = BertConfig.from_pretrained(
              "bert-base-uncased"
          )
      except OSError:
          config_path = PathManager.get_local_path(
              os.path.join(
                  opt["datapath"], "bert_base_uncased", self.CONFIG_PATH
              )
          )
          config: BertConfig = BertConfig.from_pretrained(config_path)
  
      pretrained_path = modelzoo_path(
          opt["datapath"], pretrained_path
      )  # type: ignore
      if not os.path.exists(pretrained_path):
          # when initializing from parlai rag models, the pretrained path
          # may not longer exist. This is fine if we've already trained
          # the model.
          assert dpr_model == "bert_from_parlai_rag"
          logging.error(
              f"Pretrained Path does not exist: {pretrained_path}"
          )
          pretrained_path = modelzoo_path(
              opt["datapath"], DPR_ZOO_MODEL
          )  # type: ignore
          dpr_model = "bert"
          logging.error(f"Setting to zoo model: {pretrained_path}")
      enc_opt = {
          "n_heads": config.num_attention_heads,
          "n_layers": config.num_hidden_layers,
          "embedding_size": config.hidden_size,
          "ffn_size": config.intermediate_size,
          "dropout": config.hidden_dropout_prob,
          "attention_dropout": config.attention_probs_dropout_prob,
          "activation": config.hidden_act,
          "variant": "xlm",
          "reduction_type": "first",
          "n_positions": config.max_position_embeddings,
          "n_segments": config.type_vocab_size,
      }
      embedding = torch.nn.Embedding(
          config.vocab_size,
          config.hidden_size,
          padding_idx=config.pad_token_id,
      )
      super().__init__(
          Opt(enc_opt),
          vocabulary_size=config.vocab_size,
          padding_idx=config.pad_token_id,
          embedding=embedding,
          reduction_type="first",
      )
  
      self._load_state(
          opt["datapath"], dpr_model, pretrained_path, encoder_type
      )
  
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 1 to create a new DprEncoder object from inherited base classes: TransformerEncoder with example: obj = DprEncoder(opt, dpr_model, pretrained_path, encoder_type)