code: def test_fc():
      net = nn.Sequential(nn.Linear(3, 2, bias=True))
      profiler = FlopsParamsProfiler(net, torch.randn(3))
      assert profiler.profile({}).flops == 8
  
      profiler = FlopsProfiler(net, torch.randn(3))
      assert profiler.profile({}) == 8
  
      profiler = NumParamsProfiler(net, torch.randn(3))
      assert profiler.profile({}) == 8
  
      profiler = FlopsProfiler(net, torch.randn(3), count_bias=False)
      assert profiler.profile({}) == 6
  
      # Ignore batch dim
      profiler = FlopsProfiler(net, torch.randn(2, 3))
      assert profiler.profile({}) == 8
  
      profiler = FlopsProfiler(net, torch.randn(2, 5, 3))
      assert profiler.profile({}) == 40
  
      net = nas_nn.MutableLinear(
          3, nni.choice("x", [1, 3, 5]), bias=False
      )
      profiler = FlopsProfiler(net, torch.randn(3))
      assert profiler.profile({"x": 1}) == 3
      assert profiler.profile({"x": 5}) == 15
  
file_path: nni/test/ut/nas/profiler/test_flops.py
imports: import pytest
  import torch
  from torch import nn
  import nni
  import nni.nas.nn.pytorch
  from nni.mutable import Categorical
  from nni.nas.profiler.pytorch.flops import FlopsParamsProfiler, FlopsProfiler, NumParamsProfiler, FlopsResult, register_flops_formula
  from ut.nas.nn.models import MODELS
label_desc: Use image node_id 2 for calling a global function with example usage: test_fc() without return types