code: def test_question_answering_parity(self):
      model_name_v1 = "anas-awadalla/bert-tiny-finetuned-squad"
      model_name_v2 = "mrm8488/bert-tiny-finetuned-squadv2"
  
      subprocess.run(
          "git sparse-checkout set examples/pytorch/question-answering",
          shell=True,
          cwd=os.path.join(self.dir_path, "transformers"),
      )
  
      # test squad_v1-like dataset
      subprocess.run(
          f"python examples/pytorch/question-answering/run_qa.py"
          f" --model_name_or_path {model_name_v1}"
          f" --dataset_name squad"
          f" --do_eval"
          f" --output_dir {os.path.join(self.dir_path, 'questionanswering_squad_transformers')}"
          f" --max_eval_samples 100"
          f" --max_seq_length 384",
          shell=True,
          cwd=os.path.join(self.dir_path, "transformers"),
      )
  
      with open(
          f"{os.path.join(self.dir_path, 'questionanswering_squad_transformers', 'eval_results.json')}",
          "r",
      ) as f:
          transformers_results = json.load(f)
  
      eval_dataset = load_dataset("squad", split="validation[:100]")
  
      pipe = pipeline(
          task="question-answering",
          model=model_name_v1,
          tokenizer=model_name_v1,
          max_answer_len=30,
          padding="max_length",
      )
  
      task_evaluator = evaluator(task="question-answering")
      evaluator_results = task_evaluator.compute(
          model_or_pipeline=pipe,
          data=eval_dataset,
          metric="squad",
          strategy="simple",
      )
  
      self.assertEqual(
          transformers_results["eval_f1"], evaluator_results["f1"]
      )
      self.assertEqual(
          transformers_results["eval_exact_match"],
          evaluator_results["exact_match"],
      )
  
      # test squad_v2-like dataset
      subprocess.run(
          f"python examples/pytorch/question-answering/run_qa.py"
          f" --model_name_or_path {model_name_v2}"
          f" --dataset_name squad_v2"
          f" --version_2_with_negative"
          f" --do_eval"
          f" --output_dir {os.path.join(self.dir_path, 'questionanswering_squadv2_transformers')}"
          f" --max_eval_samples 100"
          f" --max_seq_length 384",
          shell=True,
          cwd=os.path.join(self.dir_path, "transformers"),
      )
  
      with open(
          f"{os.path.join(self.dir_path, 'questionanswering_squadv2_transformers', 'eval_results.json')}",
          "r",
      ) as f:
          transformers_results = json.load(f)
  
      eval_dataset = load_dataset("squad_v2", split="validation[:100]")
  
      pipe = pipeline(
          task="question-answering",
          model=model_name_v2,
          tokenizer=model_name_v2,
          max_answer_len=30,
      )
  
      task_evaluator = evaluator(task="question-answering")
      evaluator_results = task_evaluator.compute(
          model_or_pipeline=pipe,
          data=eval_dataset,
          metric="squad_v2",
          strategy="simple",
          squad_v2_format=True,
      )
  
      self.assertEqual(
          transformers_results["eval_f1"], evaluator_results["f1"]
      )
      self.assertEqual(
          transformers_results["eval_HasAns_f1"],
          evaluator_results["HasAns_f1"],
      )
      self.assertEqual(
          transformers_results["eval_NoAns_f1"],
          evaluator_results["NoAns_f1"],
      )
  
imports: import json
  import os
  import shutil
  import subprocess
  import tempfile
  import unittest
  import numpy
  import torch
  import transformers
  from datasets import load_dataset
  from transformers import AutoFeatureExtractor, AutoModelForImageClassification, Trainer, TrainingArguments, pipeline
  from evaluate import evaluator, load
  from .utils import slow
label_desc: Use image node_id 6 for calling the TestEvaluatorTrainerParity obj's underlying member method code with example usage: obj.test_question_answering_parity() without return types