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: import numpy
  import gluonnlp.data.batchify
  import collections
  import dataclasses
  import mxnet
  from mxnet import np, npx
  from mxnet.gluon import nn
  from mxnet.gluon.nn import HybridBlock
  from dataclasses import dataclass
  from tqdm import tqdm
  from typing import Optional, List, Tuple
  from gluonnlp.data.tokenizers import BaseTokenizerWithVocab
  from gluonnlp.utils.preprocessing import match_tokens_with_char_spans
  from gluonnlp.layers import get_activation
  from gluonnlp.op import select_vectors_by_position
  from gluonnlp.attention_cell import masked_logsoftmax, masked_softmax
  import string
  import re
  import json
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