code: def __init__(
      self,
      pretrained_model: str,
      load_path: str,
      bpr_index: str,
      query_encoder_file: str,
      max_query_length: int = 256,
      top_n: int = 100,
      device: str = "gpu",
      *args,
      **kwargs,
  ):
      super().__init__(save_path=None, load_path=load_path)
      self.device = torch.device(
          "cuda"
          if torch.cuda.is_available() and device == "gpu"
          else "cpu"
      )
      self.bpr_index = bpr_index
      self.top_n = top_n
      self.max_query_length = max_query_length
      self.query_encoder_file = query_encoder_file
      self.tokenizer = AutoTokenizer.from_pretrained(
          pretrained_model, use_fast=True
      )
      self.q_encoder = BertModel.from_pretrained(pretrained_model).to(
          self.device
      )
      self.load()
      self.index = FaissBinaryIndex(self.base_index)
  
file_path: DeepPavlov/deeppavlov/models/doc_retrieval/bpr.py
imports: from typing import Tuple
  import faiss
  import numpy
  import torch
  from tqdm import trange
  from transformers import AutoTokenizer, BertModel
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.models.component import Component
  from deeppavlov.core.models.serializable import Serializable
label_desc: Use image node_id 1 to create a new BPR object from inherited base classes: Component, Serializable with example: obj = BPR(pretrained_model, load_path, bpr_index, query_encoder_file, max_query_length, top_n, device)