class_docstr: Generate Dense Embeddings.
class_docstr_tok: ["Generate","Dense","Embeddings","."]
docstr: 1) load model 2) generate embeddings 3) save embeddings.
docstr_tok: ["1",")","load","model","2",")","generate","embeddings","3",")","save","embeddings","."]
code: def run(self):
      """
      1) load model 2) generate embeddings 3) save embeddings.
      """
      self.use_cuda = (
          not self.opt.get("no_cuda") and torch.cuda.is_available()
      )
      overrides = {
          "interactive_mode": True,
          "interactive_candidates": "inline",
      }
      if self.opt["dpr_model"]:
          overrides.update(
              {
                  "model": "dpr_agent",
                  "model_file": self.opt["model_file"],
                  "share_encoders": False,
                  "override": {
                      "model": "dpr_agent",
                      "interactive_candidates": "inline",
                      "share_encoders": False,
                  },
              }
          )
          agent = create_agent(Opt(overrides))
      else:
          agent = create_agent_from_model_file(
              self.opt["model_file"], overrides
          )
      model = (
          agent.model.module
          if hasattr(agent.model, "module")
          else agent.model
      )
      assert hasattr(model, "encoder_cand") or hasattr(
          model, "cand_encoder"
      )
      assert isinstance(agent, TorchRankerAgent)
      passages = self.load_passages()
      data = self.encode_passages(agent, passages)
      self.save_data(data)
  
imports: import os
  import torch
  import torch.cuda
  from typing import List, Tuple
  from parlai.agents.transformer.transformer import TransformerRankerAgent
  from parlai.agents.transformer.polyencoder import PolyencoderAgent
  from parlai.core.agents import create_agent_from_model_file, create_agent
  from parlai.core.build_data import modelzoo_path
  from parlai.core.message import Message
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from parlai.core.script import ParlaiScript
  from parlai.core.torch_ranker_agent import TorchRankerAgent
  import parlai.utils.logging
  from parlai.agents.transformer.dropout_poly import DropoutPolyAgent
  from parlai.agents.rag.retrievers import load_passages_list
  import parlai.agents.rag.dpr
label_desc: Use image node_id 2 for calling the Generator obj's underlying member method code with example usage: obj.run() without return types