class_docstr: Stores data in-memory. It's ephemeral and cannot be saved to disk.
docstr: Retrieves documents that are most similar to the query embedding using a vector similarity metric.
  
  :param query_embedding: Embedding of the query.
  :param filters: A dictionary with filters to narrow down the search space.
  :param top_k: The number of top documents to retrieve. Default is 10.
  :param scale_score: Whether to scale the scores of the retrieved Documents. Default is False.
  :param return_embedding: Whether to return the embedding of the retrieved Documents. Default is False.
  :return: A list of the top_k documents most relevant to the query.
docstr_tok: ["Retrieves","documents","that","are","most","similar","to","the","query","embedding","using","a","vector","similarity","metric",".",":","param","query_embedding",":","Embedding","of","the","query",".",":","param","filters",":","A","dictionary","with","filters","to","narrow","down","the","search","space",".",":","param","top_k",":","The","number","of","top","documents","to","retrieve",".","Default","is","10.",":","param","scale_score",":","Whether","to","scale","the","scores","of","the","retrieved","Documents",".","Default","is","False",".",":","param","return_embedding",":","Whether","to","return","the","embedding","of","the","retrieved","Documents",".","Default","is","False",".",":","return",":","A","list","of","the","top_k","documents","most","relevant","to","the","query","."]
code: def embedding_retrieval(
      self,
      query_embedding: List[float],
      filters: Optional[Dict[str, Any]] = None,
      top_k: int = 10,
      scale_score: bool = False,
      return_embedding: bool = False,
  ) -> List[Document]:
      """
      Retrieves documents that are most similar to the query embedding using a vector similarity metric.
  
      :param query_embedding: Embedding of the query.
      :param filters: A dictionary with filters to narrow down the search space.
      :param top_k: The number of top documents to retrieve. Default is 10.
      :param scale_score: Whether to scale the scores of the retrieved Documents. Default is False.
      :param return_embedding: Whether to return the embedding of the retrieved Documents. Default is False.
      :return: A list of the top_k documents most relevant to the query.
      """
      if len(query_embedding) == 0 or not isinstance(
          query_embedding[0], float
      ):
          raise ValueError(
              "query_embedding should be a non-empty list of floats."
          )
  
      filters = filters or {}
      all_documents = self.filter_documents(filters=filters)
  
      documents_with_embeddings = [
          doc for doc in all_documents if doc.embedding is not None
      ]
      if len(documents_with_embeddings) == 0:
          logger.warning(
              "No Documents found with embeddings. Returning empty list. "
              "To generate embeddings, use a DocumentEmbedder."
          )
          return []
      elif len(documents_with_embeddings) < len(all_documents):
          logger.info(
              "Skipping some Documents that don't have an embedding. "
              "To generate embeddings, use a DocumentEmbedder."
          )
  
      scores = self._compute_query_embedding_similarity_scores(
          embedding=query_embedding,
          documents=documents_with_embeddings,
          scale_score=scale_score,
      )
  
      # create Documents with the similarity score for the top k results
      top_documents = []
      for doc, score in sorted(
          zip(documents_with_embeddings, scores),
          key=lambda x: x[1],
          reverse=True,
      )[:top_k]:
          doc_fields = doc.to_dict()
          doc_fields["score"] = score
          if return_embedding is False:
              doc_fields["embedding"] = None
          top_documents.append(Document.from_dict(doc_fields))
  
      return top_documents
  
imports: import re
  from typing import Literal, Any, Dict, List, Optional, Iterable
  import logging
  import numpy
  from haystack_bm25 import rank_bm25
  from tqdm.auto import tqdm
  from haystack import default_from_dict, default_to_dict
  from haystack.dataclasses import Document
  from haystack.document_stores.types import DuplicatePolicy
  from haystack.utils.filters import document_matches_filter, convert
  from haystack.document_stores.errors import DuplicateDocumentError, DocumentStoreError
  from haystack.utils import expit
label_desc: Use image node_id 9 for calling the InMemoryDocumentStore obj's underlying member method code with example usage: obj.embedding_retrieval(query_embedding, filters, top_k, scale_score, return_embedding) and returns: top_documents, list