code: def run(args):
      save_dir = "models"
      imgs = torch.rand((1000, 1, 3, 128, 128))
      opt = InferenceOptimizer()
      if args.option in options:
          try:
              if args.option in sub_options:
                  model = opt.load(os.path.join(save_dir, args.option))
              elif args.option in special_options:
                  model = ResNet18(10, pretrained=False)
                  model = opt.load(
                      os.path.join(save_dir, args.option),
                      model,
                      input_sample=torch.ones((1, 3, 128, 128)),
                  )
              else:
                  model = ResNet18(10, pretrained=False)
                  model = opt.load(
                      os.path.join(save_dir, args.option), model
                  )
              with InferenceOptimizer.get_context(model):
                  # warmup
                  for img in imgs[:10]:
                      _ = model(img)
  
                  st = time.time()
                  for img in imgs:
                      _ = model(img)
                  end = time.time()
              throughput = len(imgs) / (end - st)
          except Exception:
              throughput = 0
          print(f"Throughput: {throughput}")
      else:
          print(f"unkonwn option: {args.option}")
          sys.exit(-1)
  
file_path: BigDL/python/nano/benchmark/torch_inference_optimizer/inference.py
imports: import time
  import os
  import sys
  import argparse
  import torch
  from torch import nn
  from bigdl.nano.pytorch.vision.models import vision
  from bigdl.nano.pytorch import InferenceOptimizer
label_desc: Use image node_id 1 for calling a global function with example usage: run(args) without return types