<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def send(self, data):
 """ Sends data to the `AlarmDecoder`_ device. :param data: data to send :type data: string """


        if self._device:
            if isinstance(data, str):
                data = str.encode(data)

            # Hack to support unicode under Python 2.x
            if sys.version_info < (3,):
                if isinstance(data, unicode):
                    data = bytes(data)

            self._device.write(data)