code: def mock_reader(mock_tokenizer):
      class MockModel(torch.nn.Module):
          def to(self, device):
              assert device == "cpu:0"
              self.device_set = True
              return self
  
          def forward(self, input_ids, attention_mask, *args, **kwargs):
              assert input_ids.device == torch.device("cpu")
              assert attention_mask.device == torch.device("cpu")
              assert self.device_set
              start = torch.zeros(input_ids.shape[:2])
              end = torch.zeros(input_ids.shape[:2])
              start[:, 27] = 1
              end[:, 31] = 1
              end[:, 32] = 1
              prediction = Mock()
              prediction.start_logits = start
              prediction.end_logits = end
              return prediction
  
      with patch(
          "haystack.components.readers.extractive.AutoModelForQuestionAnswering.from_pretrained"
      ) as model:
          model.return_value = MockModel()
          reader = ExtractiveReader(model="mock-model", device="cpu:0")
          reader.warm_up()
          return reader
  
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 2 for calling a global function with example usage: mock_reader(mock_tokenizer) and returns: reader, self, prediction