code: def get_squad_examples_from_json(
      json_file: str, is_training: bool
  ) -> List[SquadExample]:
      """
      Read the whole entry of raw json file and convert it to examples.
  
      Parameters
      ----------
      json_file
          The path to the json file
      is_training
          Whether or not training
  
      Returns
      -------
      ret
          List of SquadExample objects
      """
      with open(json_file, "r") as f:
          data = json.load(f)
      examples = []
      for entry in tqdm(data["data"]):
          title = entry["title"]
          for paragraph in entry["paragraphs"]:
              context_text = paragraph["context"]
              for qa in paragraph["qas"]:
                  qas_id = qa["id"]
                  query_text = qa["question"]
                  start_position = None
                  end_position = None
                  answer_text = None
                  answers = None
                  if "is_impossible" in qa:
                      is_impossible = qa["is_impossible"]
                  else:
                      is_impossible = False
  
                  if not is_impossible:
                      if is_training:
                          answer = qa["answers"][0]
                          answer_text = answer["text"]
                          start_position = answer["answer_start"]
                          end_position = start_position + len(
                              answer_text
                          )
                          if (
                              context_text[start_position:end_position]
                              != answer_text
                          ):
                              warnings.warn(
                                  "Mismatch start/end and answer_text, start/end={}/{},"
                                  " answer text={}. qas={}".format(
                                      start_position,
                                      end_position,
                                      answer_text,
                                      qas_id,
                                  )
                              )
                      else:
                          answers = qa["answers"]
                  example = SquadExample(
                      qas_id=qas_id,
                      query_text=query_text,
                      context_text=context_text,
                      answer_text=answer_text,
                      start_position=start_position,
                      end_position=end_position,
                      title=title,
                      is_impossible=is_impossible,
                      answers=answers,
                  )
                  examples.append(example)
      return examples
  
imports: from typing import Optional, List, Tuple
  from collections import namedtuple
  import dataclasses
  from dataclasses import dataclass
  import re
  import numpy
  import warnings
  import os
  from tqdm.auto import tqdm
  import json
  import string
  from gluonnlp.data.tokenizers import BaseTokenizerWithVocab
  from gluonnlp.utils.preprocessing import match_tokens_with_char_spans
  from mxnet.gluon.utils import download
  import mxnet
label_desc: Use image node_id 3 for calling a global function with example usage: get_squad_examples_from_json(json_file, is_training) and returns: examples