code: def test_complexity_calculation(self) -> None:
      model = TestModel()
      input_shape = (3, 10, 10)
      num_elems = 3 * 10 * 10
      activations = num_elems + num_elems  # linear + conv
      self.assertEqual(
          compute_activations(model, input_shape=input_shape),
          activations,
      )
      self.assertEqual(
          compute_flops(model, input_shape=input_shape),
          num_elems
          + 0
          + (
              300 * 300
          ),  # TestModule + TestConvModule + TestModel.linear;
          # TestModel.unused_linear is unused and shouldn't be counted
      )
      self.assertEqual(
          count_params(model),
          (2 * 3)
          + (2 * 3 * 4 * 4)
          + (4 * 5)
          + (300 * 300)
          + (10 * 10)
          + (2 * 2),
      )  # TestModule.linear + TestConvModule + TestConvModule.linear +
      # TestModel.linear + TestModel.extra_params + TestModel.unused_linear
  
      # test that we calculate complexity correctly for a model which re-uses a module
      model = TestModel2()
      in_channels = 3
      out_channels = 3
      out_h, out_w = 9, 9
      kernel_h, kernel_w = 2, 2
      conv_flops = (
          in_channels
          * out_channels
          * out_h
          * out_w
          * kernel_h
          * kernel_w
      )
      conv_activations = out_channels * out_h * out_w
      self.assertEqual(
          compute_activations(model, input_shape=input_shape),
          conv_activations * 2,
      )  # the conv is applied twice
      self.assertEqual(
          compute_flops(model, input_shape=input_shape), conv_flops * 2
      )  # the conv is applied twice
      self.assertEqual(
          count_params(model),
          in_channels * out_channels * kernel_h * kernel_w,
      )
  
imports: import unittest
  import torch
  import torch.nn
  from classy_vision.generic.profiler import compute_activations, compute_flops, count_params, get_shape
  from classy_vision.models import build_model
  from test.generic.config_utils import get_test_model_configs
label_desc: Use image node_id 2 for calling the TestProfilerFunctions obj's underlying member method code with example usage: obj.test_complexity_calculation() without return types