def save_tiled_raster_images(tiled_img, filename):
    """
    Save a a return value from `tile_raster_images` to `filename`.

    Returns
    -------
    img : WRITEME
        The PIL image that was saved
    """
    if tiled_img.ndim==2:
        ensure_Image()
        img = Image.fromarray( tiled_img, 'L')
    elif tiled_img.ndim==3:
        ensure_Image()
        img = Image.fromarray(tiled_img, 'RGBA')
    else:
        raise TypeError('bad ndim', tiled_img)

    img.save(filename)
    return img
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/packaged_dependencies/theano_linear/imaging.py/save_tiled_raster_images/original