def vis_samples(samples):
    from PIL import ImageDraw, ImageFont
    img = image.pil_from_ndarray(np.zeros((28, 28)))

    chains = []
    num_rows = samples[0][0].shape[0]

    for row in xrange(num_rows):
        images = []
        labels = []

        for step in samples:
            assert len(step) == 2

            images.append(step[0][row])

            vec = step[1][row]
            sorted_idxs = np.argsort(vec)
            label1 = sorted_idxs[-1]
            label2 = sorted_idxs[-2]

            if vec[label1] == 0:
                ratio = 1
            else:
                ratio = vec[label2] / vec[label1]

            c = img.copy()
            draw = ImageDraw.Draw(c)
            draw.text((8, 11), str(label1), 255)
            draw.text((14, 11), str(label2), int(255 * ratio))
            nd = image.ndarray_from_pil(c)[:, :, 0]
            nd = nd.reshape((1, 784))
            labels.append(nd)

        data = safe_zip(images, labels)
        data = list(itertools.chain(*data))

        # white block to indicate end of chain
        data.extend([np.ones((1, 784))] * 2)

        chains.append(np.vstack(data))

    return np.vstack(chains)


# some utility methods for viewing MNIST characters without any GUI
See :func:`burpui.misc.backend.interface.BUIbackend.get_clients_report`
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/scripts/gsn_example.py/vis_samples--crossover with--dataset/ETHPy150Open ziirish/burp-ui/burpui/misc/backend/burp1.py/Burp.get_clients_report