class_docstr: This class evaluates a SentenceTransformer model for the task of re-ranking.
  
  Given a query and a list of documents, it computes the score [query, doc_i] for all possible
  documents and sorts them in decreasing order. Then, MRR@10 and MAP is compute to measure the quality of the ranking.
  
  :param samples: Must be a list and each element is of the form: {'query': '', 'positive': [], 'negative': []}. Query is the search query,
   positive is a list of positive (relevant) documents, negative is a list of negative (irrelevant) documents.
code: def __init__(
      self,
      samples,
      mrr_at_k: int = 10,
      name: str = "",
      write_csv: bool = True,
      similarity_fct=cos_sim,
      batch_size: int = 64,
      show_progress_bar: bool = False,
      use_batched_encoding: bool = True,
  ):
      self.samples = samples
      self.name = name
      self.mrr_at_k = mrr_at_k
      self.similarity_fct = similarity_fct
      self.batch_size = batch_size
      self.show_progress_bar = show_progress_bar
      self.use_batched_encoding = use_batched_encoding
  
      if isinstance(self.samples, dict):
          self.samples = list(self.samples.values())
  
      ### Remove sample with empty positive / negative set
      self.samples = [
          sample
          for sample in self.samples
          if len(sample["positive"]) > 0 and len(sample["negative"]) > 0
      ]
  
      self.csv_file = (
          "RerankingEvaluator"
          + ("_" + name if name else "")
          + "_results.csv"
      )
      self.csv_headers = [
          "epoch",
          "steps",
          "MAP",
          "MRR@{}".format(mrr_at_k),
      ]
      self.write_csv = write_csv
  
file_path: sentence-transformers/sentence_transformers/evaluation/RerankingEvaluator.py
imports: from .None import SentenceEvaluator
  import logging
  import numpy
  import os
  import csv
  from ..util import cos_sim
  import torch
  from sklearn.metrics import average_precision_score
  import tqdm
label_desc: Use image node_id 1 to create a new RerankingEvaluator object from inherited base classes: SentenceEvaluator with example: obj = RerankingEvaluator(samples, mrr_at_k, name, write_csv, similarity_fct, batch_size, show_progress_bar, use_batched_encoding)