code: def test_quantize_inc_ptq_compiled(self):
      # Test if a Lightning Module compiled by nano works
      train_loader_iter = iter(self.train_loader)
      trainer = Trainer(max_epochs=1)
      pl_model = Trainer.compile(self.model, self.loss, self.optimizer)
      x = next(train_loader_iter)[0]
  
      # Case 1: Default
      qmodel = InferenceOptimizer.quantize(
          pl_model, calib_data=self.train_loader
      )
      assert qmodel
      out = qmodel(x)
      assert out.shape == torch.Size([256, 10])
  
      # Case 2: Override by arguments
      qmodel = InferenceOptimizer.quantize(
          pl_model,
          calib_data=self.train_loader,
          metric=torchmetrics.F1Score("multiclass", num_classes=10),
          approach="static",
          tuning_strategy="basic",
          accuracy_criterion={
              "relative": 0.99,
              "higher_is_better": True,
          },
      )
  
      assert qmodel
      out = qmodel(x)
      assert out.shape == torch.Size([256, 10])
  
      # Case 3: Dynamic quantization
      qmodel = InferenceOptimizer.quantize(pl_model, approach="dynamic")
      assert qmodel
      out = qmodel(x)
      assert out.shape == torch.Size([256, 10])
  
      # Case 4: Invalid approach
      invalid_approach = "qat"
      with pytest.raises(
          RuntimeError,
          match="Approach should be 'static' or 'dynamic', "
          "{} is invalid.".format(invalid_approach),
      ):
          InferenceOptimizer.quantize(
              pl_model, approach=invalid_approach
          )
  
      # Case 5: Test if registered metric can be fetched successfully
      qmodel = InferenceOptimizer.quantize(
          pl_model,
          calib_data=self.train_loader,
          metric=torchmetrics.F1Score("multiclass", num_classes=10),
          accuracy_criterion={
              "relative": 0.99,
              "higher_is_better": True,
          },
      )
      assert qmodel
      out = qmodel(x)
      assert out.shape == torch.Size([256, 10])
  
      trainer.validate(qmodel, self.train_loader)
      trainer.test(qmodel, self.train_loader)
      trainer.predict(qmodel, self.train_loader)
  
      # save and load
      with tempfile.TemporaryDirectory() as tmp_dir_name:
          InferenceOptimizer.save(qmodel, tmp_dir_name)
          loaded_qmodel = InferenceOptimizer.load(
              tmp_dir_name, pl_model
          )
          assert loaded_qmodel
          out = loaded_qmodel(x)
          assert out.shape == torch.Size([256, 10])
  
imports: import os
  import operator
  import tempfile
  from unittest import TestCase
  import pytest
  import torch
  from pytorch_lightning import LightningModule
  from torch import nn
  from test.pytorch.utils._train_torch_lightning import create_data_loader, data_transform
  import torchmetrics
  from torchvision.models import resnet18
  from bigdl.nano.pytorch import Trainer
  from bigdl.nano.pytorch import InferenceOptimizer
  from bigdl.nano.pytorch.vision.models import vision
  from bigdl.nano.utils.common import invalidOperationError
  from bigdl.nano.utils.common import compare_version
  from bigdl.nano.utils.pytorch import TORCH_VERSION_LESS_2_0
  from bigdl.nano.utils.common import _avx2_checker
label_desc: Use image node_id 1 for calling the TestINC obj's underlying member method code with example usage: obj.test_quantize_inc_ptq_compiled() without return types