code: def test_nest_answers(mock_reader: ExtractiveReader):
      start = list(range(5))
      end = [i + 5 for i in start]
      start = [start] * 6  # type: ignore
      end = [end] * 6  # type: ignore
      probabilities = (
          torch.arange(5).unsqueeze(0) / 5
          + torch.arange(6).unsqueeze(-1) / 25
      )
      query_ids = [0] * 3 + [1] * 3
      document_ids = list(range(3)) * 2
      nested_answers = mock_reader._nest_answers(  # type: ignore
          start=start,
          end=end,
          probabilities=probabilities,
          flattened_documents=example_documents[0],
          queries=example_queries,
          answers_per_seq=5,
          top_k=3,
          score_threshold=None,
          query_ids=query_ids,
          document_ids=document_ids,
          no_answer=True,
          overlap_threshold=None,
      )
      expected_no_answers = [0.2 * 0.16 * 0.12, 0]
      for query, answers, expected_no_answer, probabilities in zip(
          example_queries,
          nested_answers,
          expected_no_answers,
          [probabilities[:3, -1], probabilities[3:, -1]],
      ):
          assert len(answers) == 4
          for doc, answer, score in zip(
              example_documents[0], reversed(answers[:3]), probabilities
          ):
              assert answer.query == query
              assert answer.document == doc
              assert answer.score == pytest.approx(score)
          no_answer = answers[-1]
          assert no_answer.query == query
          assert no_answer.document is None
          assert no_answer.score == pytest.approx(expected_no_answer)
  
imports: from math import ceil, exp
  from typing import List
  from unittest.mock import patch, Mock
  import pytest
  import torch
  from transformers import pipeline
  from haystack.components.readers import ExtractiveReader
  from haystack import Document, ExtractedAnswer
label_desc: Use image node_id 11 for calling a global function with example usage: test_nest_answers(mock_reader) without return types