class_docstr: Question Answering pipeline using any `ModelForQuestionAnswering`. See the [question answering
  examples](../task_summary#question-answering) for more information.
  
  Example:
  
  ```python
  >>> from transformers import pipeline
  
  >>> oracle = pipeline(model="deepset/roberta-base-squad2")
  >>> oracle(question="Where do I live?", context="My name is Wolfgang and I live in Berlin")
  {'score': 0.9191, 'start': 34, 'end': 40, 'answer': 'Berlin'}
  ```
  
  Learn more about the basics of using a pipeline in the [pipeline tutorial](../pipeline_tutorial)
  
  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",".","Example",":","``","`","python",">",">",">","from","transformers","import","pipeline",">",">",">","oracle","=","pipeline","(","model=","''","deepset\/roberta-base-squad2","''",")",">",">",">","oracle","(","question=","''","Where","do","I","live","?","``",",","context=","''","My","name","is","Wolfgang","and","I","live","in","Berlin","''",")","{","'score","'",":","0.9191",",","'start","'",":","34",",","'end","'",":","40",",","'answer","'",":","'Berlin","'","}","``","`","Learn","more","about","the","basics","of","using","a","pipeline","in","the","[","pipeline","tutorial","]","(","..","\/pipeline_tutorial",")","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",")","."]
code: def postprocess(
      self,
      model_outputs,
      top_k=1,
      handle_impossible_answer=False,
      max_answer_len=15,
      align_to_words=True,
  ):
      min_null_score = 1000000  # large and positive
      answers = []
      for output in model_outputs:
          start_ = output["start"]
          end_ = output["end"]
          example = output["example"]
          p_mask = output["p_mask"]
          attention_mask = (
              output["attention_mask"].numpy()
              if output.get("attention_mask", None) is not None
              else None
          )
  
          starts, ends, scores, min_null_score = select_starts_ends(
              start_,
              end_,
              p_mask,
              attention_mask,
              min_null_score,
              top_k,
              handle_impossible_answer,
              max_answer_len,
          )
  
          if not self.tokenizer.is_fast:
              char_to_word = np.array(example.char_to_word_offset)
  
              # Convert the answer (tokens) back to the original text
              # Score: score from the model
              # Start: Index of the first character of the answer in the context string
              # End: Index of the character following the last character of the answer in the context string
              # Answer: Plain text of the answer
              for s, e, score in zip(starts, ends, scores):
                  token_to_orig_map = output["token_to_orig_map"]
                  answers.append(
                      {
                          "score": score.item(),
                          "start": np.where(
                              char_to_word == token_to_orig_map[s]
                          )[0][0].item(),
                          "end": np.where(
                              char_to_word == token_to_orig_map[e]
                          )[0][-1].item(),
                          "answer": " ".join(
                              example.doc_tokens[
                                  token_to_orig_map[
                                      s
                                  ] : token_to_orig_map[e]
                                  + 1
                              ]
                          ),
                      }
                  )
          else:
              # Convert the answer (tokens) back to the original text
              # Score: score from the model
              # Start: Index of the first character of the answer in the context string
              # End: Index of the character following the last character of the answer in the context string
              # Answer: Plain text of the answer
              question_first = bool(
                  self.tokenizer.padding_side == "right"
              )
              enc = output["encoding"]
  
              # Encoding was *not* padded, input_ids *might*.
              # It doesn't make a difference unless we're padding on
              # the left hand side, since now we have different offsets
              # everywhere.
              if self.tokenizer.padding_side == "left":
                  offset = (
                      (
                          output["input_ids"]
                          == self.tokenizer.pad_token_id
                      )
                      .numpy()
                      .sum()
                  )
              else:
                  offset = 0
  
              # Sometimes the max probability token is in the middle of a word so:
              # - we start by finding the right word containing the token with `token_to_word`
              # - then we convert this word in a character span with `word_to_chars`
              sequence_index = 1 if question_first else 0
              for s, e, score in zip(starts, ends, scores):
                  s = s - offset
                  e = e - offset
  
                  start_index, end_index = self.get_indices(
                      enc, s, e, sequence_index, align_to_words
                  )
  
                  answers.append(
                      {
                          "score": score.item(),
                          "start": start_index,
                          "end": end_index,
                          "answer": example.context_text[
                              start_index:end_index
                          ],
                      }
                  )
  
      if handle_impossible_answer:
          answers.append(
              {
                  "score": min_null_score,
                  "start": 0,
                  "end": 0,
                  "answer": "",
              }
          )
      answers = sorted(answers, key=lambda x: x["score"], reverse=True)[
          :top_k
      ]
      if len(answers) == 1:
          return answers[0]
      return answers
  
imports: import inspect
  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 7 for calling the QuestionAnsweringPipeline obj's underlying member method code with example usage: obj.postprocess(model_outputs, top_k, handle_impossible_answer, max_answer_len, align_to_words) and returns: answers, answers