<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def compress(data, compression, width, height, depth, version=1):
 """Compress raw data. :param data: raw data bytes to write. :param compression: compression type, see :py:class:`.Compression`. :param width: width. :param height: height. :param depth: bit depth of the pixel. :param version: psd file version. :return: compressed data bytes. """

    if compression == Compression.RAW:
        result = data
    elif compression == Compression.PACK_BITS:
        result = encode_packbits(data, width, height, depth, version)
    elif compression == Compression.ZIP:
        result = zlib.compress(data)
    else:
        encoded = encode_prediction(data, width, height, depth)
        result = zlib.compress(encoded)

    return result