<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_tile(codec, tile_index, data, data_size, stream):
 """Wraps openjp2 library function opj_write_tile. Write a tile into an image. Parameters codec : CODEC_TYPE The jpeg2000 codec tile_index : int The index of the tile to write, zero-indexing assumed data : array Image data arranged in usual C-order data_size : int Size of a tile in bytes stream : STREAM_TYPE_P The stream to write data to Raises ------ RuntimeError If the OpenJPEG library routine opj_write_tile fails. """

    OPENJP2.opj_write_tile.argtypes = [CODEC_TYPE,
                                       ctypes.c_uint32,
                                       ctypes.POINTER(ctypes.c_uint8),
                                       ctypes.c_uint32,
                                       STREAM_TYPE_P]
    OPENJP2.opj_write_tile.restype = check_error

    datap = data.ctypes.data_as(ctypes.POINTER(ctypes.c_uint8))
    OPENJP2.opj_write_tile(codec,
                           ctypes.c_uint32(int(tile_index)),
                           datap,
                           ctypes.c_uint32(int(data_size)),
                           stream)