Stopping the code along with a graceful shutdown.
Is there a way to stop the training in the model when some criteria are satisfied. Something along the lines:
class myCallback(Callback):
    def __init__(self):
        ...
    def on_epoch_end(self, trainer, pl_module):
        if criteria:
            model.stop_training = True # stops the training; need help here

Note that I also want to have the early stopping feature where the 'val_loss' is monitored but want to stop running the code if some other criteria is satisfied. Also, is my method of having this feature in the callback module correct or should I inherit the early stopping criteria?