code: def test_question_answering_parity(self):
      model_name = "mrm8488/bert-tiny-finetuned-squadv2"
      n_samples = 100
  
      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}"
          f" --dataset_name squad"
          f" --do_eval"
          f" --output_dir {os.path.join(self.dir_path, 'questionanswering_squad_transformers')}"
          f" --max_eval_samples {n_samples}"
          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)
  
      subprocess.run(
          f"python3 examples/onnxruntime/quantization/question-answering/run_qa.py"
          f" --model_name_or_path {model_name}"
          f" --dataset_name squad"
          f" --do_eval"
          f" --output_dir {self.dir_path}/questionanswering_squad_optimum"
          f" --max_eval_samples {n_samples}"
          f" --quantization_approach dynamic"
          f" --max_seq_length 384",
          shell=True,
      )
  
      with open(
          os.path.join(
              self.dir_path,
              "questionanswering_squad_optimum",
              "eval_results.json",
          ),
          "r",
      ) as f:
          optimum_results = json.load(f)
  
      run_config = {
          "task": "question-answering",
          "model_name_or_path": model_name,
          "dataset": {
              "path": "squad",
              "eval_split": "validation",
              "data_keys": {
                  "question": "question",
                  "context": "context",
              },
              "ref_keys": ["answers"],
          },
          "metrics": ["squad"],
          "quantization_approach": "dynamic",
          "operators_to_quantize": ["Add", "MatMul"],
          "node_exclusion": [],
          "per_channel": False,
          "framework": "onnxruntime",
          "framework_args": {"optimization_level": 1},
          "batch_sizes": [8],
          "input_lengths": [128],
          "max_eval_samples": n_samples,
          "time_benchmark_args": {"warmup_runs": 0, "duration": 0},
      }
      run_config = RunConfig(**run_config)
      run_config = dataclasses.asdict(run_config)
  
      run_instance = OnnxRuntimeRun(run_config)
      benchmark_results = run_instance.launch()
  
      self.assertEqual(
          transformers_results["eval_f1"],
          benchmark_results["evaluation"]["others"]["baseline"]["f1"],
      )
      self.assertEqual(
          transformers_results["eval_exact_match"],
          benchmark_results["evaluation"]["others"]["baseline"][
              "exact_match"
          ],
      )
  
      self.assertEqual(
          optimum_results["f1"],
          benchmark_results["evaluation"]["others"]["optimized"]["f1"],
      )
      self.assertEqual(
          optimum_results["exact_match"],
          benchmark_results["evaluation"]["others"]["optimized"][
              "exact_match"
          ],
      )
  
file_path: optimum/tests/benchmark/test_transformers_optimum_examples_parity.py
imports: import dataclasses
  import json
  import os
  import shutil
  import subprocess
  import tempfile
  import unittest
  import transformers
  from optimum.onnxruntime.runs import OnnxRuntimeRun
  from optimum.utils.runs import RunConfig
label_desc: Use image node_id 5 for calling the TestParity obj's underlying member method code with example usage: obj.test_question_answering_parity() without return types