def _create_question(context, answer, question, id_):
  """Find answer in context and create question."""
  match = re.search(re.escape(answer), context, re.IGNORECASE)
  if match is not None:
    answers = [answer],
    detected_answers = [{
        "char_spans": [[match.start(), match.end() - 1]],
        "text": context[match.start():match.end()],
    }]
    is_impossible = False
  else:
    answers = []
    detected_answers = []
    is_impossible = True
  return {
      "context":
          context,
      "qas": [{
          "qid": id_,
          "is_impossible": is_impossible,
          "question": question,
          "answers": answers,
          "detected_answers": detected_answers,
      }],
  }
Find answer in context and create question.
language/labs/drkit/hotpotqa/preprocessing/convert_hotpot_to_mrqa.py