class_docstr: A component that locates and extract answers to a given query from Documents. It's used for performing extractive
  QA. The Reader assigns a score to every possible answer span independently of other answer spans.
  This fixes a common issue of other implementations which make comparisons across documents harder by normalizing
  each document's answers independently.
  
  Example usage:
  ```python
  p = Pipeline()
  p.add_component(instance=InMemoryBM25Retriever(document_store=InMemoryDocumentStore()), name="retriever")
  p.add_component(instance=ExtractiveReader(), name="reader")
  p.connect("retriever", "reader")
  question = "Who lives in Berlin?"
  p.run({"retriever": {"query": question}, "reader": {"query": question}})
  ```
docstr: Locates and extracts answers from the given Documents using the given query.
  
  :param query: Query string.
  :param documents: List of Documents in which you want to search for an answer to the query.
  :param top_k: The maximum number of answers to return.
      An additional answer is returned if no_answer is set to True (default).
  :param score_threshold: Returns only answers with the score above this threshold.
  :param max_seq_length: Maximum number of tokens.
      If a sequence exceeds it, the sequence is split.
      Default: 384
  :param stride: Number of tokens that overlap when sequence is split because it exceeds max_seq_length.
      Default: 128
  :param max_batch_size: Maximum number of samples that are fed through the model at the same time.
  :param answers_per_seq: Number of answer candidates to consider per sequence.
      This is relevant when a Document was split into multiple sequences because of max_seq_length.
      Default: 20
  :param no_answer: Whether to return no answer scores.
      Default: True
  :param overlap_threshold: If set this will remove duplicate answers if they have an overlap larger than the
      supplied threshold. For example, for the answers "in the river in Maine" and "the river" we would remove
      one of these answers since the second answer has a 100% (1.0) overlap with the first answer.
      However, for the answers "the river in" and "in Maine" there is only a max overlap percentage of 25% so
      both of these answers could be kept if this variable is set to 0.24 or lower.
      If None is provided then all answers are kept.
      Default: 0.01
  :return: List of ExtractedAnswers sorted by (desc.) answer score.
docstr_tok: ["Locates","and","extracts","answers","from","the","given","Documents","using","the","given","query",".",":","param","query",":","Query","string",".",":","param","documents",":","List","of","Documents","in","which","you","want","to","search","for","an","answer","to","the","query",".",":","param","top_k",":","The","maximum","number","of","answers","to","return",".","An","additional","answer","is","returned","if","no_answer","is","set","to","True","(","default",")",".",":","param","score_threshold",":","Returns","only","answers","with","the","score","above","this","threshold",".",":","param","max_seq_length",":","Maximum","number","of","tokens",".","If","a","sequence","exceeds","it",",","the","sequence","is","split",".","Default",":","384",":","param","stride",":","Number","of","tokens","that","overlap","when","sequence","is","split","because","it","exceeds","max_seq_length",".","Default",":","128",":","param","max_batch_size",":","Maximum","number","of","samples","that","are","fed","through","the","model","at","the","same","time",".",":","param","answers_per_seq",":","Number","of","answer","candidates","to","consider","per","sequence",".","This","is","relevant","when","a","Document","was","split","into","multiple","sequences","because","of","max_seq_length",".","Default",":","20",":","param","no_answer",":","Whether","to","return","no","answer","scores",".","Default",":","True",":","param","overlap_threshold",":","If","set","this","will","remove","duplicate","answers","if","they","have","an","overlap","larger","than","the","supplied","threshold",".","For","example",",","for","the","answers","``","in","the","river","in","Maine","''","and","``","the","river","''","we","would","remove","one","of","these","answers","since","the","second","answer","has","a","100","%","(","1.0",")","overlap","with","the","first","answer",".","However",",","for","the","answers","``","the","river","in","''","and","``","in","Maine","''","there","is","only","a","max","overlap","percentage","of","25","%","so","both","of","these","answers","could","be","kept","if","this","variable","is","set","to","0.24","or","lower",".","If","None","is","provided","then","all","answers","are","kept",".","Default",":","0.01",":","return",":","List","of","ExtractedAnswers","sorted","by","(","desc",".",")","answer","score","."]
code: def run(
      self,
      query: str,
      documents: List[Document],
      top_k: Optional[int] = None,
      score_threshold: Optional[float] = None,
      max_seq_length: Optional[int] = None,
      stride: Optional[int] = None,
      max_batch_size: Optional[int] = None,
      answers_per_seq: Optional[int] = None,
      no_answer: Optional[bool] = None,
      overlap_threshold: Optional[float] = None,
  ):
      """
      Locates and extracts answers from the given Documents using the given query.
  
      :param query: Query string.
      :param documents: List of Documents in which you want to search for an answer to the query.
      :param top_k: The maximum number of answers to return.
          An additional answer is returned if no_answer is set to True (default).
      :param score_threshold: Returns only answers with the score above this threshold.
      :param max_seq_length: Maximum number of tokens.
          If a sequence exceeds it, the sequence is split.
          Default: 384
      :param stride: Number of tokens that overlap when sequence is split because it exceeds max_seq_length.
          Default: 128
      :param max_batch_size: Maximum number of samples that are fed through the model at the same time.
      :param answers_per_seq: Number of answer candidates to consider per sequence.
          This is relevant when a Document was split into multiple sequences because of max_seq_length.
          Default: 20
      :param no_answer: Whether to return no answer scores.
          Default: True
      :param overlap_threshold: If set this will remove duplicate answers if they have an overlap larger than the
          supplied threshold. For example, for the answers "in the river in Maine" and "the river" we would remove
          one of these answers since the second answer has a 100% (1.0) overlap with the first answer.
          However, for the answers "the river in" and "in Maine" there is only a max overlap percentage of 25% so
          both of these answers could be kept if this variable is set to 0.24 or lower.
          If None is provided then all answers are kept.
          Default: 0.01
      :return: List of ExtractedAnswers sorted by (desc.) answer score.
      """
      queries = [
          query
      ]  # Temporary solution until we have decided what batching should look like in v2
      nested_documents = [documents]
      if self.model is None:
          raise ComponentError(
              "The component was not warmed up. Run 'warm_up()' before calling 'run()'."
          )
  
      top_k = top_k or self.top_k
      score_threshold = score_threshold or self.score_threshold
      max_seq_length = max_seq_length or self.max_seq_length
      stride = stride or self.stride
      max_batch_size = max_batch_size or self.max_batch_size
      answers_per_seq = answers_per_seq or self.answers_per_seq or 20
      no_answer = no_answer if no_answer is not None else self.no_answer
      overlap_threshold = overlap_threshold or self.overlap_threshold
  
      (
          flattened_queries,
          flattened_documents,
          query_ids,
      ) = self._flatten_documents(queries, nested_documents)
      (
          input_ids,
          attention_mask,
          sequence_ids,
          encodings,
          query_ids,
          document_ids,
      ) = self._preprocess(
          flattened_queries,
          flattened_documents,
          max_seq_length,
          query_ids,
          stride,
      )
  
      num_batches = (
          math.ceil(input_ids.shape[0] / max_batch_size)
          if max_batch_size
          else 1
      )
      batch_size = max_batch_size or input_ids.shape[0]
  
      start_logits_list = []
      end_logits_list = []
  
      for i in range(num_batches):
          start_index = i * batch_size
          end_index = start_index + batch_size
          cur_input_ids = input_ids[start_index:end_index]
          cur_attention_mask = attention_mask[start_index:end_index]
  
          output = self.model(
              input_ids=cur_input_ids, attention_mask=cur_attention_mask
          )
          cur_start_logits = output.start_logits
          cur_end_logits = output.end_logits
          if num_batches != 1:
              cur_start_logits = cur_start_logits.cpu()
              cur_end_logits = cur_end_logits.cpu()
          start_logits_list.append(cur_start_logits)
          end_logits_list.append(cur_end_logits)
  
      start_logits = torch.cat(start_logits_list)
      end_logits = torch.cat(end_logits_list)
  
      start, end, probabilities = self._postprocess(
          start_logits,
          end_logits,
          sequence_ids,
          attention_mask,
          answers_per_seq,
          encodings,
      )
  
      answers = self._nest_answers(
          start=start,
          end=end,
          probabilities=probabilities,
          flattened_documents=flattened_documents,
          queries=queries,
          answers_per_seq=answers_per_seq,
          top_k=top_k,
          score_threshold=score_threshold,
          query_ids=query_ids,
          document_ids=document_ids,
          no_answer=no_answer,
          overlap_threshold=overlap_threshold,
      )
  
      return {"answers": answers[0]}
  
imports: from pathlib import Path
  from typing import Any, Dict, List, Optional, Tuple, Union
  import math
  import warnings
  import logging
  from haystack import component, default_to_dict, default_from_dict, ComponentError, Document, ExtractedAnswer
  from haystack.lazy_imports import LazyImport
  from haystack.utils import get_device
label_desc: Use image node_id 13 for calling the ExtractiveReader obj's underlying member method code with example usage: obj.run(query, documents, top_k, score_threshold, max_seq_length, stride, max_batch_size, answers_per_seq, no_answer, overlap_threshold) and returns: dict