code: def optimize():
      data_dir = "data"
      save_dir = "models"
  
      model = ResNet18(10, pretrained=False)
      # loader = create_data_loader(data_dir)
      loader = DataLoader(
          TensorDataset(
              torch.rand(100, 3, 128, 128),
              torch.randint(0, 10, size=(100, 1)),
          )
      )
      opt = InferenceOptimizer()
      if "OMP_NUM_THREADS" in os.environ:
          thread_num = int(os.environ["OMP_NUM_THREADS"])
      else:
          thread_num = None
  
      opt.optimize(
          model=model,
          training_data=loader,
          thread_num=thread_num,
          search_mode="all",
      )
  
      os.makedirs(save_dir, exist_ok=True)
      options = list(
          InferenceOptimizer.ALL_INFERENCE_ACCELERATION_METHOD.keys()
      )
      for option in options:
          try:
              model = opt.get_model(option)
              opt.save(model, os.path.join(save_dir, option))
          except Exception:
              pass
  
file_path: BigDL/python/nano/benchmark/torch_inference_optimizer/optimize.py
imports: import os
  import torch
  from torch import nn
  from torch.utils.data import DataLoader
  from torch.utils.data import TensorDataset
  from torchvision import transforms
  from torchvision.datasets import CIFAR10
  from bigdl.nano.pytorch.vision.models import vision
  from bigdl.nano.pytorch import InferenceOptimizer
label_desc: Use image node_id 2 for calling a global function with example usage: optimize() without return types