code: def test_mobilenet_v3():
      net = MobileNetV3Space()
      input = ShapeTensor(torch.randn(2, 3, 224, 224), True)
      output = shape_inference(net, input)
      assert output.real_shape == MutableShape(2, 1000)
  
      sample = {}
      real_model = net.random(sample)
      shapes = submodule_input_output_shapes(net, input)
      input_shapes = {
          k: v[0][0].freeze(sample) for k, v in shapes.items()
      }  # unwrap tuple
      output_shapes = {
          k: v[1].freeze(sample) for k, v in shapes.items()
      }
  
      expected_shapes = _real_shape_inference(
          real_model, torch.randn(2, 3, 224, 224)
      )
      expected_input_shapes = {
          k: v[0][0] for k, v in expected_shapes.items()
      }
      expected_output_shapes = {
          k: v[1] for k, v in expected_shapes.items()
      }
  
      for k in input_shapes:
          if k in expected_input_shapes:
              assert input_shapes[k] == expected_input_shapes[k]
              assert output_shapes[k] == expected_output_shapes[k]
          # could be blocks.x.blocks.y. Rewrite it as blocks.x.y
          elif re.match(r"blocks\.\d+\.blocks\.\d+", k):
              k_ = re.sub(
                  r"blocks\.(\d+)\.blocks\.(\d+)", r"blocks.\1.\2", k
              )
              if k_ in expected_input_shapes:
                  assert input_shapes[k] == expected_input_shapes[k_]
                  assert output_shapes[k] == expected_output_shapes[k_]
          else:
              assert False, f"Unexpected key {k}"
  
file_path: nni/test/algo/nas/profiler/test_shape.py
imports: import re
  from functools import partial
  import torch
  from nni.nas.hub.pytorch import *
  from nni.nas.profiler.pytorch.utils import *
label_desc: Use image node_id 3 for calling a global function with example usage: test_mobilenet_v3() without return types