code: def _test_modules(self, module, clf_name):
      old_param_total = sum(
          [torch.numel(p) for p in module.parameters()]
      )
  
      module = as_multitask(module, clf_name)
      module = module.to(self.device)
      self.assertIsInstance(module, MultiTaskModule)
      self.assertIsInstance(
          getattr(module, clf_name), MultiHeadClassifier
      )
  
      test_input = torch.ones(5, 3, 32, 32)
      task_labels = torch.zeros(5, dtype=torch.long)
  
      test_input = test_input.to(self.device)
      task_labels = task_labels.to(self.device)
  
      # One task label
      output = module(test_input, task_labels=0)
  
      # Several ones
      output = module(test_input, task_labels=task_labels)
  
      # Change attribute
      module.non_module_attribute = 10
      self.assertEqual(module.model.non_module_attribute, 10)
  
      module.non_module_attribute += 5
  
      # Extract params and state dict
      new_param_total = sum(
          [torch.numel(p) for p in module.parameters()]
      )
      self.assertEqual(new_param_total, old_param_total)
      state = module.state_dict()
  
      # Functions returning references
      module = module.train()
      self.assertIsInstance(module, MultiTaskModule)
      self.assertTrue(module.training)
      module = module.eval()
      self.assertIsInstance(module, MultiTaskModule)
      self.assertFalse(module.training)
      if self.device == "cuda":
          module = module.cuda()
          self.assertIsInstance(module, MultiTaskModule)
  
file_path: avalanche/tests/models/test_helper_method.py
imports: import copy
  import unittest
  import torch
  from torch.optim import SGD
  from avalanche.models import SimpleCNN, SimpleMLP, as_multitask
  from avalanche.models.dynamic_modules import MultiTaskModule, MultiHeadClassifier
  from avalanche.training.plugins import LwFPlugin, EWCPlugin
  from avalanche.training.supervised import Naive
  from tests.unit_tests_utils import common_setups, get_fast_benchmark, get_device
label_desc: Use image node_id 7 for calling the ConversionMethodTests obj's underlying member method code with example usage: obj._test_modules(module, clf_name) without return types