def METHOD_NAME(self, trainer):
    import torch
    from .utils import SparseLinear, convert_sparse_network
    if self.save_dir is None:
        self.save_dir = trainer.work_dir
    if len(self.compress_module) == 0:
        convert_sparse_network(
            trainer.model,
            pruning_method=self.pruning_method,
            weight_rank=self.weight_rank,
            weight_beta=self.weight_beta,
            mask_rank=self.mask_rank,
            mask_alpha1=self.mask_alpha1,
            mask_alpha2=self.mask_alpha2,
            logger=trainer.logger,
        )
    else:
        for cm in self.compress_module:
            for name, module in trainer.model.named_modules():
                if name != cm:
                    continue
                convert_sparse_network(
                    module,
                    pruning_method=self.pruning_method,
                    weight_rank=self.weight_rank,
                    weight_beta=self.weight_beta,
                    mask_rank=self.mask_rank,
                    mask_alpha1=self.mask_alpha1,
                    mask_alpha2=self.mask_alpha2,
                    logger=trainer.logger,
                )
    for i in range(len(trainer.optimizer.param_groups)):
        new_train_params = []
        for param in trainer.optimizer.param_groups[i]['params']:
            is_find = False
            for name, module in trainer.model.named_modules():
                if isinstance(module, SparseLinear):
                    if torch.equal(param.half(),
                                   module.weight.data.half()):
                        is_find = True
                        break
            if not is_find:
                new_train_params.append(param)
        trainer.optimizer.param_groups[i]['params'] = new_train_params
    new_params = []
    for name, module in trainer.model.named_modules():
        if isinstance(module, SparseLinear):
            new_params.extend(
                [p for p in module.parameters() if p.requires_grad])
    trainer.optimizer.add_param_group({'params': new_params})
    self.total_step = trainer.iters_per_epoch * trainer._max_epochs