def test_optimizer_groups_rename(self):
        """
        Tests the correct reassignation to
        existing parameter groups after
        parameter renaming
        """
        model, criterion, benchmark = self.init_scenario(multi_task=False)

        g1 = []
        g2 = []
        for n, p in model.named_parameters():
            if "classifier" in n:
                g1.append(p)
            else:
                g2.append(p)

        optimizer = SGD([{"params": g1, "lr": 0.1}, {"params": g2, "lr": 0.05}])

        strategy = Naive(
            model=model,
            optimizer=optimizer,
            criterion=criterion,
            train_mb_size=64,
            device=self.device,
            eval_mb_size=50,
            train_epochs=2,
        )

        strategy.make_optimizer()

        # Check parameter groups
        for n, p in model.named_parameters():
            assert self._is_param_in_optimizer(p, strategy.optimizer)
            if "classifier" in n:
                self.assertEqual(
                    self._is_param_in_optimizer_group(p, strategy.optimizer), 0
                )
            else:
                self.assertEqual(
                    self._is_param_in_optimizer_group(p, strategy.optimizer), 1
                )

        # Rename parameters
        strategy.model = TorchWrapper(strategy.model)

        strategy.make_optimizer()

        # Check parameter groups are still the same
        for n, p in model.named_parameters():
            assert self._is_param_in_optimizer(p, strategy.optimizer)
            if "classifier" in n:
                self.assertEqual(
                    self._is_param_in_optimizer_group(p, strategy.optimizer), 0
                )
            else:
                self.assertEqual(
                    self._is_param_in_optimizer_group(p, strategy.optimizer), 1
                )

        Tests the correct reassignation to
        existing parameter groups after
        parameter renaming
        
tests/test_optimizer.py