<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def roller(timestamps, contract_dates, get_weights, **kwargs):
 """ Calculate weight allocations to tradeable instruments for generic futures at a set of timestamps for a given root generic. Paramters --------- timestamps: iterable Sorted iterable of of pandas.Timestamps to calculate weights for contract_dates: pandas.Series Series with index of tradeable contract names and pandas.Timestamps representing the last date of the roll as values, sorted by values. Index must be unique and values must be strictly monotonic. get_weights: function A function which takes in a timestamp, contract_dates, validate_inputs and **kwargs. Returns a list of tuples consisting of the generic instrument name, the tradeable contract as a string, the weight on this contract as a float and the date as a pandas.Timestamp. kwargs: keyword arguments Arguements to pass to get_weights Return ------ A pandas.DataFrame with columns representing generics and a MultiIndex of date and contract. Values represent weights on tradeables for each generic. Examples -------- """

    timestamps = sorted(timestamps)
    contract_dates = contract_dates.sort_values()
    _check_contract_dates(contract_dates)
    weights = []
    # for loop speedup only validate inputs the first function call to
    # get_weights()
    validate_inputs = True
    ts = timestamps[0]
    weights.extend(get_weights(ts, contract_dates,
                               validate_inputs=validate_inputs, **kwargs))
    validate_inputs = False
    for ts in timestamps[1:]:
        weights.extend(get_weights(ts, contract_dates,
                                   validate_inputs=validate_inputs, **kwargs))

    weights = aggregate_weights(weights)
    return weights