def reset_optimizer(optimizer, model):
    """Reset the optimizer to update the list of learnable parameters.

    .. warning::
        This function fails if the optimizer uses multiple parameter groups.

    :param optimizer:
    :param model:
    :return:
    """
    if len(optimizer.param_groups) != 1:
        raise ValueError(
            "This function only supports single parameter groups."
            "If you need to use multiple parameter groups, "
            "you can override `make_optimizer` in the Avalanche strategy."
        )
    optimizer.state = defaultdict(dict)

    parameters = []
    optimized_param_id = {}
    for n, p in model.named_parameters():
        optimized_param_id[n] = p
        parameters.append(p)

    optimizer.param_groups[0]["params"] = parameters

    return optimized_param_id
Reset the optimizer to update the list of learnable parameters.

    .. warning::
        This function fails if the optimizer uses multiple parameter groups.

    :param optimizer:
    :param model:
    :return:
    
avalanche/models/dynamic_optimizers.py