code: def mock_tokenizer():
      def mock_tokenize(
          texts: List[str],
          text_pairs: List[str],
          padding: bool,
          truncation: bool,
          max_length: int,
          return_tensors: str,
          return_overflowing_tokens: bool,
          stride: int,
      ):
          assert padding
          assert truncation
          assert return_tensors == "pt"
          assert return_overflowing_tokens
  
          tokens = Mock()
  
          num_splits = [
              ceil(len(text + pair) / max_length)
              for text, pair in zip(texts, text_pairs)
          ]
          tokens.overflow_to_sample_mapping = [
              i for i, num in enumerate(num_splits) for _ in range(num)
          ]
          num_samples = sum(num_splits)
          tokens.encodings = [Mock() for _ in range(num_samples)]
          sequence_ids = (
              [0] * 16 + [1] * 16 + [None] * (max_length - 32)
          )
          for encoding in tokens.encodings:
              encoding.sequence_ids = sequence_ids
              encoding.token_to_chars = lambda i: (i - 16, i - 15)
          tokens.input_ids = torch.zeros(
              num_samples, max_length, dtype=torch.int
          )
          attention_mask = torch.zeros(
              num_samples, max_length, dtype=torch.int
          )
          attention_mask[:32] = 1
          tokens.attention_mask = attention_mask
          return tokens
  
      with patch(
          "haystack.components.readers.extractive.AutoTokenizer.from_pretrained"
      ) as tokenizer:
          tokenizer.return_value = mock_tokenize
          yield tokenizer
  
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 1 for calling a global function with example usage: mock_tokenizer() and returns: tokens