<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def bytes_available(device):
 """ Determines the number of bytes available for reading from an AlarmDecoder device :param device: the AlarmDecoder device :type device: :py:class:`~alarmdecoder.devices.Device` :returns: int """

    bytes_avail = 0

    if isinstance(device, alarmdecoder.devices.SerialDevice):
        if hasattr(device._device, "in_waiting"):
            bytes_avail = device._device.in_waiting
        else:
            bytes_avail = device._device.inWaiting()
    elif isinstance(device, alarmdecoder.devices.SocketDevice):
        bytes_avail = 4096

    return bytes_avail