<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pyglet_image_loader(filename, colorkey, **kwargs):
 """basic image loading with pyglet returns pyglet Images, not textures This is a basic proof-of-concept and is likely to fail in some situations. Missing: Transparency Tile Rotation This is slow as well. """

    if colorkey:
        logger.debug('colorkey not implemented')

    image = pyglet.image.load(filename)

    def load_image(rect=None, flags=None):
        if rect:
            try:
                x, y, w, h = rect
                y = image.height - y - h
                tile = image.get_region(x, y, w, h)
            except:
                logger.error('cannot get region %s of image', rect)
                raise
        else:
            tile = image

        if flags:
            logger.error('tile flags are not implemented')

        return tile

    return load_image