class_docstr: How2 Video Retriver.
  Reference usage of FAISS:
  https://github.com/fairinternal/fairseq-py/blob/paraphrase_pretraining/fairseq/data/multilingual_faiss_dataset.py
class_docstr_tok: ["How2","Video","Retriver",".","Reference","usage","of","FAISS",":","https",":","\/\/github.com\/fairinternal\/fairseq-py\/blob\/paraphrase_pretraining\/fairseq\/data\/multilingual_faiss_dataset.py"]
code: def search_by_video_ids(self, video_ids, retri_factor):
      if len(self.videoid_to_vectoridx) != self.db.ntotal:
          raise ValueError(
              len(self.videoid_to_vectoridx), self.db.ntotal
          )
  
      if not self.make_direct_maps_done:
          self.make_direct_maps()
  
      if self.vectoridx_to_videoid is None:
          self.vectoridx_to_videoid = {
              self.videoid_to_vectoridx[videoid]: videoid
              for videoid in self.videoid_to_vectoridx
          }
          assert len(self.vectoridx_to_videoid) == len(
              self.videoid_to_vectoridx
          )
  
      query_hidden_states = []
      vector_ids = []
      for video_id in video_ids:
          vector_id = self.videoid_to_vectoridx[video_id]
          vector_ids.append(vector_id)
          query_hidden_state = self.db.reconstruct(vector_id)
          query_hidden_states.append(query_hidden_state)
      query_hidden_states = np.stack(query_hidden_states)
  
      # MultilingualFaissDataset uses the following; not sure the reason.
      # faiss.ParameterSpace().set_index_parameter(self.db, "nprobe", 10)
      _, index = self.db.search(query_hidden_states, retri_factor)
      outputs = []
      for sample_idx, sample in enumerate(index):
          # the first video_id is always the video itself.
          cands = [video_ids[sample_idx]]
          for vector_idx in sample:
              if (
                  vector_idx >= 0
                  and vector_ids[sample_idx] != vector_idx
              ):
                  cands.append(self.vectoridx_to_videoid[vector_idx])
          outputs.append(cands)
      return outputs
  
imports: import os
  import numpy
  import pickle
  import time
  from collections import defaultdict
  from ..utils import get_local_rank, print_on_rank0
label_desc: Use image node_id 9 for calling the VectorRetriever obj's underlying member method code with example usage: obj.search_by_video_ids(video_ids, retri_factor) and returns: outputs