<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def toggle(self):
 """ Reverse the state of the device. If it's on, turn it off; if it's off, turn it on. """

        with self._lock:
            if self.is_active:
                self.off()
            else:
                self.on()