class_docstr: We use this callback to control the number of training epochs in incremental
  training. Epoch & step counts are not reset in the checkpoint. If we were to set
  `max_epochs` on the trainer, we would have to keep track of the previous `max_epochs`
  and add to it manually. This keeps the infomation in one place.
  
  Note that we need to set `_cleanly_stopped` back to True before saving the checkpoint.
  This is done in `ModelManager.save_trainer()`.
class_docstr_tok: ["We","use","this","callback","to","control","the","number","of","training","epochs","in","incremental","training",".","Epoch","&","step","counts","are","not","reset","in","the","checkpoint",".","If","we","were","to","set","`","max_epochs","`","on","the","trainer",",","we","would","have","to","keep","track","of","the","previous","`","max_epochs","`","and","add","to","it","manually",".","This","keeps","the","infomation","in","one","place",".","Note","that","we","need","to","set","`","_cleanly_stopped","`","back","to","True","before","saving","the","checkpoint",".","This","is","done","in","`","ModelManager.save_trainer","(",")","`","."]
code: def on_pretrain_routine_end(self, trainer, pl_module):
      assert isinstance(pl_module, ReAgentLightningModule)
      cleanly_stopped = pl_module._cleanly_stopped.item()
      logger.info(f"cleanly stopped: {cleanly_stopped}")
      if cleanly_stopped:
          pl_module.increase_next_stopping_epochs(self.num_epochs)
  
imports: import inspect
  import logging
  import pytorch_lightning
  import torch
  from reagent.core.tensorboardX import SummaryWriterContext
  from reagent.core.utils import lazy_property
  from typing_extensions import final
label_desc: Use image node_id 2 for calling the StoppingEpochCallback obj's underlying member method code with example usage: obj.on_pretrain_routine_end(trainer, pl_module) without return types