this comment post mentions how to use dataset and map to process your data, please go through this, i also have provided how to correct the code, and if it’s matches how I mentioned to write the code and still you have got label is not defined, then one needs to check train_val_dataset codes.
let me know if you want me to review your codes still.