def METHOD_NAME(rule):
    swap_weights = [*rule['weights']]
    class_num = len(rule['to'])
    weight_num = len(rule['weights'])
    # Remove excess weights if present
    if weight_num > class_num:
        swap_weights = rule['weights'][:class_num]
    # Grow the weights to match number of classes
    elif weight_num < class_num:
        swap_weights += [1] * (class_num-weight_num)
    return swap_weights