How to skip the batch if condition true(like perprlexity>10)?

When i use return None in training_step() it’s report clip_gradients got an error. I want to know how to skip a batch in trainging_step() when condition is True, the chatgpt tell to use return {“loss”:loss, “skipped”: True}, is there any document? Tanks.