def get_weights(cbf):
    """Retrieve the latest gain corrections and their corresponding update times."""
    weights, times = {}, {}
    for sensor_name in cbf.sensor:
        if sensor_name.endswith('_gain_correction_per_channel'):
            sensor = cbf.sensor[sensor_name]
            input_name = sensor_name.split('_')[1]
            reading = sensor.get_reading()
            weights[input_name] = reading.value
            times[input_name] = reading.timestamp
    return weights, times