def METHOD_NAME(top_p_sampler):
    ws = WebSearch(api_key=os.environ.get("SERPERDEV_API_KEY", None))
    ranker = SentenceTransformersRanker(model_name_or_path="cross-encoder/ms-marco-MiniLM-L-6-v2", top_k=2)
    pipe = Pipeline()
    pipe.add_node(component=ws, name="ws", inputs=["Query"])
    pipe.add_node(component=top_p_sampler, name="sampler", inputs=["ws"])
    pipe.add_node(component=ranker, name="ranker", inputs=["sampler"])
    result = pipe.run(query="Who is the boyfriend of Olivia Wilde?")
    assert "documents" in result
    assert len(result["documents"]) == 2
    assert isinstance(result["documents"][0], Document)