code: def test_postprocess(mock_reader: ExtractiveReader):
      start = torch.zeros((2, 8))
      start[0, 3] = 4
      start[0, 1] = 5  # test attention_mask
      start[0, 4] = 3
      start[1, 2] = 1
  
      end = torch.zeros((2, 8))
      end[0, 1] = 5  # test attention_mask
      end[0, 2] = 4  # test that end can't be before start
      end[0, 3] = 3
      end[0, 4] = 2
      end[1, :] = -10
      end[1, 4] = -1
  
      sequence_ids = torch.ones((2, 8))
      attention_mask = torch.ones((2, 8))
      attention_mask[0, :2] = 0
      encoding = Mock()
      encoding.token_to_chars = lambda i: (int(i), int(i) + 1)
  
      (
          start_candidates,
          end_candidates,
          probs,
      ) = mock_reader._postprocess(
          start,
          end,
          sequence_ids,
          attention_mask,
          3,
          [encoding, encoding],
      )
  
      assert (
          len(start_candidates)
          == len(end_candidates)
          == len(probs)
          == 2
      )
      assert (
          len(start_candidates[0])
          == len(end_candidates[0])
          == len(probs[0])
          == 3
      )
      assert start_candidates[0][0] == 3
      assert end_candidates[0][0] == 4
      assert start_candidates[0][1] == 3
      assert end_candidates[0][1] == 5
      assert start_candidates[0][2] == 4
      assert end_candidates[0][2] == 5
      assert probs[0][0] == pytest.approx(
          1 / (1 + exp(-7 * mock_reader.calibration_factor))
      )
      assert probs[0][1] == pytest.approx(
          1 / (1 + exp(-6 * mock_reader.calibration_factor))
      )
      assert probs[0][2] == pytest.approx(
          1 / (1 + exp(-5 * mock_reader.calibration_factor))
      )
      assert start_candidates[1][0] == 2
      assert end_candidates[1][0] == 5
      assert probs[1][0] == pytest.approx(1 / 2)
  
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 10 for calling a global function with example usage: test_postprocess(mock_reader) without return types