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","."]
docstr: Load pre-trained model states.
  
  :param dpr_model:
      which dpr model type we're using
  :param pretrained_path:
      path to pretrained model
  :param encoder_type:
      whether this is a query or document encoder
docstr_tok: ["Load","pre-trained","model","states",".",":","param","dpr_model",":","which","dpr","model","type","we","'re","using",":","param","pretrained_path",":","path","to","pretrained","model",":","param","encoder_type",":","whether","this","is","a","query","or","document","encoder"]
code: def _load_state(
      self,
      datapath: str,
      dpr_model: str,
      pretrained_path: str,
      encoder_type: str,
  ):
      """
      Load pre-trained model states.
  
      :param dpr_model:
          which dpr model type we're using
      :param pretrained_path:
          path to pretrained model
      :param encoder_type:
          whether this is a query or document encoder
      """
      if dpr_model == "bert":
          state_dict = BertConversionUtils.load_bert_state(
              datapath,
              self.state_dict(),
              pretrained_dpr_path=pretrained_path,
              encoder_type=encoder_type,
          )
          self.load_state_dict(state_dict)
      elif dpr_model == "bert_from_parlai_rag":
          state_dict = torch.load(pretrained_path, map_location="cpu")[
              "model"
          ]
          key = f"{encoder_type}_encoder."
          state_dict = {
              k.split(key)[-1]: v
              for k, v in state_dict.items()
              if key in k
          }
          self.load_state_dict(state_dict)
  
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 2 for calling the DprEncoder obj's underlying member method code with example usage: obj._load_state(datapath, dpr_model, pretrained_path, encoder_type) without return types