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: Determine if the answer should be kept based on how much it overlaps with previous answers.
  
  NOTE: We might want to avoid throwing away answers that only have a few character (or word) overlap:
      - E.g. The answers "the river in" and "in Maine" from the context "I want to go to the river in Maine."
      might both want to be kept.
  
  :param candidate_answer: Candidate answer that will be checked if it should be kept.
  :param current_answers: Current list of answers that will be kept.
  :param overlap_threshold: If the overlap between two answers is greater than this threshold then return False.
docstr_tok: ["Determine","if","the","answer","should","be","kept","based","on","how","much","it","overlaps","with","previous","answers",".","NOTE",":","We","might","want","to","avoid","throwing","away","answers","that","only","have","a","few","character","(","or","word",")","overlap",":","-","E.g",".","The","answers","``","the","river","in","''","and","``","in","Maine","''","from","the","context","``","I","want","to","go","to","the","river","in","Maine",".","''","might","both","want","to","be","kept",".",":","param","candidate_answer",":","Candidate","answer","that","will","be","checked","if","it","should","be","kept",".",":","param","current_answers",":","Current","list","of","answers","that","will","be","kept",".",":","param","overlap_threshold",":","If","the","overlap","between","two","answers","is","greater","than","this","threshold","then","return","False","."]
code: def _should_keep(
      self,
      candidate_answer: ExtractedAnswer,
      current_answers: List[ExtractedAnswer],
      overlap_threshold: float,
  ) -> bool:
      """
      Determine if the answer should be kept based on how much it overlaps with previous answers.
  
      NOTE: We might want to avoid throwing away answers that only have a few character (or word) overlap:
          - E.g. The answers "the river in" and "in Maine" from the context "I want to go to the river in Maine."
          might both want to be kept.
  
      :param candidate_answer: Candidate answer that will be checked if it should be kept.
      :param current_answers: Current list of answers that will be kept.
      :param overlap_threshold: If the overlap between two answers is greater than this threshold then return False.
      """
      keep = True
  
      # If the candidate answer doesn't have a document keep it
      if not candidate_answer.document:
          return keep
  
      for ans in current_answers:
          # If an answer in current_answers doesn't have a document skip the comparison
          if not ans.document:
              continue
  
          # If offset is missing then keep both
          if ans.document_offset is None:
              continue
  
          # If offset is missing then keep both
          if candidate_answer.document_offset is None:
              continue
  
          # If the answers come from different documents then keep both
          if candidate_answer.document.id != ans.document.id:
              continue
  
          overlap_len = self._calculate_overlap(
              answer1_start=ans.document_offset.start,
              answer1_end=ans.document_offset.end,
              answer2_start=candidate_answer.document_offset.start,
              answer2_end=candidate_answer.document_offset.end,
          )
  
          # If overlap is 0 then keep
          if overlap_len == 0:
              continue
  
          overlap_frac_answer1 = overlap_len / (
              ans.document_offset.end - ans.document_offset.start
          )
          overlap_frac_answer2 = overlap_len / (
              candidate_answer.document_offset.end
              - candidate_answer.document_offset.start
          )
  
          if (
              overlap_frac_answer1 > overlap_threshold
              or overlap_frac_answer2 > overlap_threshold
          ):
              keep = False
              break
  
      return keep
  
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 11 for calling the ExtractiveReader obj's underlying member method code with example usage: obj._should_keep(candidate_answer, current_answers, overlap_threshold) and returns: keep, keep