class_docstr: Question Answering pipeline using any `ModelForQuestionAnswering`. See the [question answering
  examples](../task_summary#question-answering) for more information.
  
  This question answering pipeline can currently be loaded from [`pipeline`] using the following task identifier:
  `"question-answering"`.
  
  The models that this pipeline can use are models that have been fine-tuned on a question answering task. See the
  up-to-date list of available models on
  [huggingface.co/models](https://huggingface.co/models?filter=question-answering).
class_docstr_tok: ["Question","Answering","pipeline","using","any","`","ModelForQuestionAnswering","`",".","See","the","[","question","answering","examples","]","(","..","\/task_summary","#","question-answering",")","for","more","information",".","This","question","answering","pipeline","can","currently","be","loaded","from","[","`","pipeline","`","]","using","the","following","task","identifier",":","`","``","question-answering","''","`",".","The","models","that","this","pipeline","can","use","are","models","that","have","been","fine-tuned","on","a","question","answering","task",".","See","the","up-to-date","list","of","available","models","on","[","huggingface.co\/models","]","(","https",":","\/\/huggingface.co\/models","?","filter=question-answering",")","."]
docstr: When decoding from token probabilities, this method maps token indexes to actual word in the initial context.
  
  Args:
      text (`str`): The actual context to extract the answer from.
      start (`int`): The answer starting token index.
      end (`int`): The answer end token index.
  
  Returns:
      Dictionary like `{'answer': str, 'start': int, 'end': int}`
docstr_tok: ["When","decoding","from","token","probabilities",",","this","method","maps","token","indexes","to","actual","word","in","the","initial","context",".","Args",":","text","(","`","str","`",")",":","The","actual","context","to","extract","the","answer","from",".","start","(","`","int","`",")",":","The","answer","starting","token","index",".","end","(","`","int","`",")",":","The","answer","end","token","index",".","Returns",":","Dictionary","like","`","{","'answer","'",":","str",",","'start","'",":","int",",","'end","'",":","int","}","`"]
code: def span_to_answer(
      self, text: str, start: int, end: int
  ) -> Dict[str, Union[str, int]]:
      """
      When decoding from token probabilities, this method maps token indexes to actual word in the initial context.
  
      Args:
          text (`str`): The actual context to extract the answer from.
          start (`int`): The answer starting token index.
          end (`int`): The answer end token index.
  
      Returns:
          Dictionary like `{'answer': str, 'start': int, 'end': int}`
      """
      words = []
      token_idx = char_start_idx = char_end_idx = chars_idx = 0
  
      for i, word in enumerate(text.split(" ")):
          token = self.tokenizer.tokenize(word)
  
          # Append words if they are in the span
          if start <= token_idx <= end:
              if token_idx == start:
                  char_start_idx = chars_idx
  
              if token_idx == end:
                  char_end_idx = chars_idx + len(word)
  
              words += [word]
  
          # Stop if we went over the end of the answer
          if token_idx > end:
              break
  
          # Append the subtokenization length to the running index
          token_idx += len(token)
          chars_idx += len(word) + 1
  
      # Join text with spaces
      return {
          "answer": " ".join(words),
          "start": max(0, char_start_idx),
          "end": min(len(text), char_end_idx),
      }
  
imports: import types
  import warnings
  from collections.abc import Iterable
  from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union
  import numpy
  from ..data import SquadExample, SquadFeatures, squad_convert_examples_to_features
  from ..modelcard import ModelCard
  from ..tokenization_utils import PreTrainedTokenizer
  from ..utils import PaddingStrategy, add_end_docstrings, is_tf_available, is_tokenizers_available, is_torch_available, logging
  from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline
label_desc: Use image node_id 9 for calling the QuestionAnsweringPipeline obj's underlying member method code with example usage: obj.span_to_answer(text, start, end) and returns: dict