def get_groups(parameters, opt_params, tensor=True):
    """Return layer-wise optimization hyper-parameters."""
    groups = []
    for p, lr, mom in zip(parameters, opt_params.lr, opt_params.momentum):
        if not tensor:
            lr = lr.item()
            mom = mom.item()
        groups.append({'params': p, 'lr': lr, 'momentum': mom})
    return groups