This error message is a bit misleading since it “Expected” and “Got” do not match because of -1 and 0, but not because -1 are not “post”. So make sure you use pad value of -1 (and also how your label_ids are constructed).
As for Exercise 5 and the mask creation - you need to check if the labels (the y_true) do not equal -1. One way of doing it could be (y_true != -1) which would return a boolean tensor which later you would need to cast to tf.float32) and that would be your mask.
Cheers