def flatten_image_arrays(imarrays):
    """Given a 3d array of images (array of 2-dim arrays), flatten it
    to a 2d array (array of 1-dim arrays)"""
    return imarrays.reshape(imarrays.shape[0], -1)