def init_viewer(dataset, rows, cols, vis_batch):
    """
    Initialisation of the PatchViewer with given rows and columns.

    Parameters
    ----------
    dataset: pylearn2 dataset
    rows: int
    cols: int
    vis_batch: numpy array
    """
    m = rows * cols
    _, patch_rows, patch_cols, channels = vis_batch.shape

    assert _ == m

    mapback = hasattr(dataset, 'mapback_for_viewer')
    actual_cols = 2 * cols * (1 + mapback) * (1 + (channels == 2))
    pv = PatchViewer((rows, actual_cols),
                     (patch_rows, patch_cols),
                     is_color=(channels == 3))
    return pv
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/scripts/dbm/show_reconstructions.py/init_viewer/original