code: def test_flops_calculation(self):
      # test that a model containing a custom module which doesn't have FLOPs defined
      # raises an exception
      model = nn.Sequential(TestModuleWithoutFlops())
      input_shape = (3, 10, 10)
      with self.assertRaises(Exception):
          compute_flops(model, input_shape=input_shape)
  
      # test that a model containing a custom module does have FLOPs defined works,
      # even if the module has children which don't define FLOPs
      model = nn.Sequential(TestModuleWithFlops())
      input_shape = (3, 10, 10)
      self.assertEqual(
          compute_flops(model, input_shape=input_shape),
          TestModuleWithFlops._flops,
      )  # the conv is applied twice
  
      # test that a model has a module which takes two positional arguments
      model = nn.Sequential(TestModuleDoubleValue())
      input_shape = (10,)
      self.assertEqual(
          compute_flops(model, input_shape=input_shape), 110
      )
  
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 3 for calling the TestProfilerFunctions obj's underlying member method code with example usage: obj.test_flops_calculation() without return types