class_docstr: Generate Dense Embeddings.
class_docstr_tok: ["Generate","Dense","Embeddings","."]
docstr: Save data.
  
  :param data:
      encoded passages, and corresponding ids
docstr_tok: ["Save","data",".",":","param","data",":","encoded","passages",",","and","corresponding","ids"]
code: def save_data(self, data: Tuple[torch.Tensor, List[str]]):
      """
      Save data.
  
      :param data:
          encoded passages, and corresponding ids
      """
      encoding, ids = data
      assert len(ids) == encoding.size(0)
      embs_outfile = f"{self.opt['outfile']}_{self.opt['shard_id']}.pt"
      logging.info(f"Writing results to {embs_outfile}")
      torch.save(encoding, embs_outfile)
      outdir = os.path.split(self.opt["outfile"])[0]
      ids_outfile = os.path.join(outdir, f"ids_{self.opt['shard_id']}")
      logging.info(f"Writing ids to {ids_outfile}")
      torch.save(ids, ids_outfile)
  
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 5 for calling the Generator obj's underlying member method code with example usage: obj.save_data(data) without return types