code: def test_autoformer():
      net = AutoFormer()
  
      sample = {}
      model = net.random(sample)
      flops, params, _ = count_flops_params(
          model, torch.randn(1, 3, 224, 224)
      )
  
      profiler = FlopsParamsProfiler(
          net,
          torch.randn(1, 3, 224, 224),
          count_bias=False,
          count_normalization=False,
          count_activation=False,
      )
      result = profiler.profile(sample)
  
      assert 0.9 < result.params / params < 1.1
      # sanity check so far
  
      model = AutoFormer.load_searched_model("autoformer-tiny")
      profiler = FlopsParamsProfiler(
          model,
          torch.randn(1, 3, 224, 224),
          count_bias=False,
          count_normalization=False,
          count_activation=False,
      )
      result = profiler.profile({})
      assert 5.7e6 < result.params < 5.8e6
      assert 1.4e9 < result.flops < 1.5e9
  
file_path: nni/test/algo/nas/profiler/test_flops.py
imports: import torch
  from nni.compression.utils.counter import count_flops_params
  from nni.nas.hub.pytorch import ProxylessNAS, MobileNetV3Space, AutoFormer, ShuffleNetSpace
  from nni.nas.profiler.pytorch.flops import FlopsParamsProfiler
label_desc: Use image node_id 3 for calling a global function with example usage: test_autoformer() without return types