code: def _generate_v2_examples(filepath):
      """Returns v2 examples."""
      with epath.Path(filepath).open() as f:
          squad = json.load(f)
          for article in squad["data"]:
              title = article.get("title", "")
              for paragraph in article["paragraphs"]:
                  context = paragraph["context"]
                  for qa in paragraph["qas"]:
                      id_ = qa["id"]
  
                      #  Not all examples have plausible answers
                      if "plausible_answers" not in qa:
                          qa["plausible_answers"] = []
  
                      question = qa["question"]
                      is_impossible = qa["is_impossible"]
  
                      plausible_answer_starts = [
                          plausible_answer["answer_start"]
                          for plausible_answer in qa[
                              "plausible_answers"
                          ]
                      ]
                      plausible_answers = [
                          plausible_answer["text"]
                          for plausible_answer in qa[
                              "plausible_answers"
                          ]
                      ]
  
                      answer_starts = [
                          answer["answer_start"]
                          for answer in qa["answers"]
                      ]
                      answers = [
                          answer["text"] for answer in qa["answers"]
                      ]
  
                      yield id_, {
                          "title": title,
                          "context": context,
                          "question": question,
                          "id": id_,
                          "plausible_answers": {
                              "answer_start": plausible_answer_starts,
                              "text": plausible_answers,
                          },
                          "answers": {
                              "answer_start": answer_starts,
                              "text": answers,
                          },
                          "is_impossible": is_impossible,
                      }
  
file_path: datasets/tensorflow_datasets/datasets/squad/squad_dataset_builder.py
imports: from __future__ import annotations
  import json
  import os
  from etils import epath
  import numpy
  import tensorflow_datasets.public_api
  from tensorflow_datasets.question_answering import qa_utils
label_desc: Use image node_id 2 for calling a global function with example usage: _generate_v2_examples(filepath) without return types