class_docstr: PreemptionCallback class creates a callback that checks for preemption during training at the end of every step.
  Upon preemption the callback provides a function to gracefully exit the training immediately and also saves the current state in a checkpoint as *last.ckpt. 
  (to be able to start from the same step without wasting any compute while resuming the next time).
  
  PreemptionCallback is always enabled by default via the arg create_preemption_callback under ExpManagerConfig. To disable please pass
  create_preemption_callback: False in your config file.
class_docstr_tok: ["PreemptionCallback","class","creates","a","callback","that","checks","for","preemption","during","training","at","the","end","of","every","step",".","Upon","preemption","the","callback","provides","a","function","to","gracefully","exit","the","training","immediately","and","also","saves","the","current","state","in","a","checkpoint","as","*","last.ckpt",".","(","to","be","able","to","start","from","the","same","step","without","wasting","any","compute","while","resuming","the","next","time",")",".","PreemptionCallback","is","always","enabled","by","default","via","the","arg","create_preemption_callback","under","ExpManagerConfig",".","To","disable","please","pass","create_preemption_callback",":","False","in","your","config","file","."]
code: def interrupted(self):
      interrupted = torch.tensor(
          self._interrupted,
          device=torch.cuda.current_device(),
          dtype=torch.int32,
      )
      torch.distributed.broadcast(interrupted, 0)
      interrupted = bool(interrupted.item())
      return interrupted
  
file_path: NeMo/nemo/utils/callbacks/preemption.py
imports: import signal
  import sys
  import torch
  from pytorch_lightning.callbacks import Callback
  from nemo.utils import logging
label_desc: Use image node_id 2 for calling the PreemptionCallback obj's underlying member method code with example usage: obj.interrupted() and returns: interrupted