def METHOD_NAME(self, trainer, pl_module):
    """
    Defines custom handlers at the beginning of training to be executed when the 
    preemption signal is received.
    """
    # Check if torch distributed is initialised, as its needed for broadcasting the preemption signal to all the ranks
    if not (torch.distributed.is_available() and torch.distributed.is_initialized()):
        logging.info("Preemption requires torch distributed to be initialized, disabling preemption")
    else:
        self.preemption_enabled = True
        # Bool var that's initialized to false and made True upon receving the preemption signal
        self._interrupted = False
        self.released = False
        self.original_handler = signal.getsignal(self.sig)
        # Master handler executed only by rank 0 when the preemption siganal is received, to avoid deadlock conditions
        def master_handler(signum, frame):
            self.release()
            self._interrupted = True
        # Handler executed by the non zero ranks
        def ignoring_handler(signum, frame):
            self.release()
        self.private_rank = torch.distributed.get_rank()
        if self.private_rank == 0:
            signal.signal(self.sig, master_handler)
        else:
            signal.signal(self.sig, ignoring_handler)
    return self