code: def test_ipex_quantization(self):
      model = ResNet18(
          10, pretrained=False, include_top=False, freeze=True
      )
      # test dataloader contains x+y
      data_loader = create_data_loader(
          data_dir, batch_size, num_workers, data_transform
      )
      inc_model = InferenceOptimizer.quantize(
          model,
          precision="int8",
          accelerator=None,
          method="ipex",
          calib_data=data_loader,
      )
      # test context manager
      with InferenceOptimizer.get_context(inc_model):
          inc_model(self.data_sample)
  
      # test save & load
      import operator
  
      if compare_version("neural_compressor", operator.ge, "2.0"):
          with tempfile.TemporaryDirectory() as tmp_dir_name:
              InferenceOptimizer.save(inc_model, tmp_dir_name)
              new_model = InferenceOptimizer.load(
                  tmp_dir_name,
                  model,
                  input_sample=next(iter(data_loader))[0],
              )
          with InferenceOptimizer.get_context(new_model):
              new_model(self.data_sample)
  
      # test dataloader only contains x
      from torchvision.models import resnet18
  
      model = resnet18()
      x = torch.rand((10, 3, 256, 256))
      ds = TensorDataset(x)
      dataloader = DataLoader(ds, batch_size=2)
      model = InferenceOptimizer.quantize(
          model,
          precision="int8",
          accelerator=None,
          method="ipex",
          calib_data=dataloader,
      )
      with InferenceOptimizer.get_context(model):
          model(x)
  
      # test single sample
      from torchvision.models import resnet18
  
      model = resnet18()
      x = torch.rand((10, 3, 256, 256))
      model = InferenceOptimizer.quantize(
          model,
          precision="int8",
          accelerator=None,
          method="ipex",
          calib_data=x,
      )
      with InferenceOptimizer.get_context(model):
          model(x)
  
      # test multi input
      for model_class in [MultipleInputNet, MultipleInputWithKwargsNet]:
          net = model_class()
          x1 = torch.randn(32, 10)
          x2 = torch.randn(32, 10)
          y = torch.randn(32, 1)
          if isinstance(net, MultipleInputNet):
              dataloader = DataLoader(
                  TensorDataset(x1, x2, y), batch_size=1
              )
          else:
              x3 = torch.randn(32, 1)
              dataloader = DataLoader(
                  TensorDataset(x1, x2, x3, y), batch_size=1
              )
  
          model = InferenceOptimizer.quantize(
              net,
              precision="int8",
              accelerator=None,
              method="ipex",
              calib_data=dataloader,
          )
          with InferenceOptimizer.get_context(model):
              if isinstance(net, MultipleInputNet):
                  model(x1, x2)
              else:
                  model(x1, x2, x3)
  
imports: import os
  from unittest import TestCase
  import operator
  import pytest
  import torch
  from torch.utils.data import TensorDataset, DataLoader, Dataset
  from test.pytorch.utils._train_torch_lightning import create_data_loader, data_transform
  from torch import nn
  import operator
  from bigdl.nano.pytorch import InferenceOptimizer
  from bigdl.nano.pytorch.vision.models import vision
  from bigdl.nano.utils.pytorch import TORCH_VERSION_LESS_1_10, TORCH_VERSION_LESS_2_0
  from bigdl.nano.utils.common import compare_version, _avx512_checker, _avx2_checker
  import tempfile
  from typing import List
  import numpy
label_desc: Use image node_id 12 for calling the IPEXJITInference obj's underlying member method code with example usage: obj.test_ipex_quantization() without return types