def map_per_batch(fun, values, batch_indices):
    result = []
    for (start, stop, value_slice) in sliced_per_batch(values, batch_indices):
        result.append(fun(start, stop, value_slice))
    return torch.cat(result)
def map_per_batch(fun, values, batch_indices):
    result = []
    for (start, stop, value_slice) in sliced_per_batch(values, batch_indices):
        result.append(fun(start, stop, value_slice))
    return torch.cat(result)