code: def test_quantizer_step_mechanism(quantization_scheme):
      model = nn.Sequential(
          OrderedDict(
              {
                  "conv": nn.Conv2d(1, 20, (3, 3)),
                  "bn": nn.BatchNorm2d(20),
                  "relu": nn.ReLU(),
              }
          )
      )
  
      config = LinearQuantizerConfig.from_dict(
          {
              "global_config": {
                  "quantization_scheme": quantization_scheme,
                  "milestones": [0, 1, 2, 3],
              }
          }
      )
      quantizer = LinearQuantizer(model, config)
      model = quantizer.prepare(
          example_inputs=torch.randn(1, 1, 28, 28)
      )
  
      assert not model.activation_post_process_0.observer_enabled
      assert not model.activation_post_process_0.fake_quant_enabled
      assert not model.activation_post_process_1.observer_enabled
      assert not model.activation_post_process_1.fake_quant_enabled
  
      for idx in range(4):
          quantizer.step()
          if idx == 0:
              assert not model.conv.freeze_bn
              assert model.activation_post_process_0.observer_enabled
              assert (
                  not model.activation_post_process_0.fake_quant_enabled
              )
              assert model.activation_post_process_1.observer_enabled
              assert (
                  not model.activation_post_process_1.fake_quant_enabled
              )
          if idx == 1:
              assert not model.conv.freeze_bn
              assert model.activation_post_process_0.observer_enabled
              assert model.activation_post_process_0.fake_quant_enabled
              assert model.activation_post_process_1.observer_enabled
              assert model.activation_post_process_1.fake_quant_enabled
          if idx == 2:
              assert not model.conv.freeze_bn
              assert (
                  not model.activation_post_process_0.observer_enabled
              )
              assert model.activation_post_process_0.fake_quant_enabled
              assert (
                  not model.activation_post_process_1.observer_enabled
              )
              assert model.activation_post_process_1.fake_quant_enabled
          if idx == 3:
              assert model.conv.freeze_bn
              assert (
                  not model.activation_post_process_0.observer_enabled
              )
              assert model.activation_post_process_0.fake_quant_enabled
              assert (
                  not model.activation_post_process_1.observer_enabled
              )
              assert model.activation_post_process_1.fake_quant_enabled
  
file_path: coremltools/coremltools/test/optimize/torch/quantization/test_quantizer.py
imports: from collections import OrderedDict
  import cattrs
  import pytest
  import torch
  import torch.ao.quantization
  import torch.nn
  import torch.nn.intrinsic
  import torch.nn.intrinsic.qat
  import torch.nn.quantized
  import torch.nn.quantized.modules.utils
  from coremltools.optimize.torch.quantization import LinearQuantizer, LinearQuantizerConfig, ModuleLinearQuantizerConfig
label_desc: Use image node_id 7 for calling a global function with example usage: test_quantizer_step_mechanism(quantization_scheme) without return types