<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def heartbeat(self):
        '''Record the current worker state in the registry.

        This records the worker's current mode, plus the contents of
        :meth:`environment`, in the data store for inspection by others.

        :returns mode: Current mode, as :meth:`TaskMaster.get_mode`

        '''
        mode = self.task_master.get_mode()
        self.task_master.worker_heartbeat(self.worker_id, mode,
                                          self.lifetime, self.environment(),
                                          parent=self.parent)
        return mode