TabularList.from_df: label_from_func resets index for validation set to 0

I’m trying to build an auto-encoder. I am using the following data construct:

tl = TabularList.from_df(df, cat_names=cat_names, cont_names=cont_names, procs=procs)

def get_y_fn(i):
    return tl[i]

data = tl\
    .label_from_func(get_y_fn, label_cls=FloatList)\

This works nicely, but when training, the i passed into get_y_fn always starts from 0, no matter whether the training or validation set is being used. So return tl[i] always returns data from the training set, because the indices for the validation set start from for example 50000.
Is there any way to determine in get_y_fn whether we’re working with the training or the validation set?
Thank you.