class_docstr: Test InMemoryDocumentStore's specific features
class_docstr_tok: ["Test","InMemoryDocumentStore","'s","specific","features"]
code: def test_bm25_retrieval_with_different_top_k(
      self, document_store: InMemoryDocumentStore
  ):
      # Tests if the bm25_retrieval method correctly changes the number of returned documents
      # based on the top_k parameter.
      docs = [
          Document(content="Hello world"),
          Document(content="Haystack supports multiple languages"),
          Document(content="Python is a popular programming language"),
      ]
      document_store.write_documents(docs)
  
      # top_k = 2
      results = document_store.bm25_retrieval(query="language", top_k=2)
      assert len(results) == 2
  
      # top_k = 3
      results = document_store.bm25_retrieval(
          query="languages", top_k=3
      )
      assert len(results) == 3
  
imports: import logging
  from unittest.mock import patch
  import pandas
  import pytest
  from haystack import Document
  from haystack.document_stores.errors import DocumentStoreError, DuplicateDocumentError
  from haystack.document_stores.in_memory import InMemoryDocumentStore
  from haystack.testing.document_store import DocumentStoreBaseTests
label_desc: Use image node_id 9 for calling the TestMemoryDocumentStore obj's underlying member method code with example usage: obj.test_bm25_retrieval_with_different_top_k(document_store) without return types