code: def throughput(
      args, model_path, forecaster, train_loader, test_loader, records
  ):
      """
      throughput stage will record inference throughput.
      """
  
      try:
          # load trained model
          forecaster.load(model_path)
      except:
          # if no ckpt can be used, then train a new one
          forecaster.fit(train_loader, epochs=1)
  
      # dataset size
      if args.framework == "tensorflow":
          inference_sample_num = sum(
              [x.shape[0] for x, _ in test_loader]
          )
      else:
          inference_sample_num = len(test_loader.dataset)
  
      if args.quantize:
          import onnxruntime
  
          sess_options = onnxruntime.SessionOptions()
          if args.cores:
              sess_options.intra_op_num_threads = args.cores
              sess_options.inter_op_num_threads = args.cores
          forecaster.quantize(
              test_loader,
              framework=args.quantize_type,
              sess_options=sess_options,
              thread_num=args.cores if args.cores else None,
          )
          print("QUANTIZATION DONE")
  
      # predict
      if "torch" in args.inference_framework:
          import torch
  
          st = time.time()
          yhat = forecaster.predict(test_loader, quantize=args.quantize)
          total_time = time.time() - st
          records["torch_infer_throughput"] = (
              inference_sample_num / total_time
          )
  
      # predict with onnx
      if "onnx" in args.inference_framework:
          if args.cores and not args.quantize:
              forecaster.build_onnx(thread_num=args.cores)
          st = time.time()
          yhat = forecaster.predict_with_onnx(
              test_loader, quantize=args.quantize
          )
          total_time = time.time() - st
          records["onnx_infer_throughput"] = (
              inference_sample_num / total_time
          )
  
      # predict with openvino
      if "openvino" in args.inference_framework:
          if args.cores and not args.quantize:
              forecaster.build_openvino(thread_num=args.cores)
          st = time.time()
          yhat = forecaster.predict_with_openvino(
              test_loader, quantize=args.quantize
          )
          total_time = time.time() - st
          records["openvino_infer_throughput"] = (
              inference_sample_num / total_time
          )
  
      # predict with jit
      if "jit" in args.inference_framework:
          if args.cores:
              forecaster.build_jit(thread_num=args.cores)
          st = time.time()
          yhat = forecaster.predict_with_jit(
              test_loader, quantize=args.quantize
          )
          total_time = time.time() - st
          records["jit_infer_throughput"] = (
              inference_sample_num / total_time
          )
  
file_path: BigDL/python/chronos/src/bigdl/chronos/benchmark/benchmark_chronos.py
imports: from bigdl.chronos.benchmark import generate_forecaster, generate_data, get_CPU_info, check_nano_env
  import time
  import numpy
  import argparse
  import os
  from scipy import stats
  import psutil
  import subprocess
  from bigdl.nano.utils.common import invalidInputError
  from bigdl.nano.utils.common import spawn_new_process
label_desc: Use image node_id 2 for calling a global function with example usage: throughput(args, model_path, forecaster, train_loader, test_loader, records) without return types