def CNN2d(CNN=None, second=<NUM_LIT:10>, saveable=True, name='<STR_LIT>', fig_idx=<NUM_LIT>):
import matplotlib.pyplot as plt<EOL>n_mask = CNN.shape[<NUM_LIT:3>]<EOL>n_row = CNN.shape[<NUM_LIT:0>]<EOL>n_col = CNN.shape[<NUM_LIT:1>]<EOL>n_color = CNN.shape[<NUM_LIT:2>]<EOL>row = int(np.sqrt(n_mask))<EOL>col = int(np.ceil(n_mask / row))<EOL>plt.ion()  <EOL>fig = plt.figure(fig_idx)<EOL>count = <NUM_LIT:1><EOL>for _ir in range(<NUM_LIT:1>, row + <NUM_LIT:1>):<EOL><INDENT>for _ic in range(<NUM_LIT:1>, col + <NUM_LIT:1>):<EOL><INDENT>if count > n_mask:<EOL><INDENT>break<EOL><DEDENT>fig.add_subplot(col, row, count)<EOL>if n_color == <NUM_LIT:1>:<EOL><INDENT>plt.imshow(np.reshape(CNN[:, :, :, count - <NUM_LIT:1>], (n_row, n_col)), cmap='<STR_LIT>', interpolation="<STR_LIT>")<EOL><DEDENT>elif n_color == <NUM_LIT:3>:<EOL><INDENT>plt.imshow(<EOL>np.reshape(CNN[:, :, :, count - <NUM_LIT:1>], (n_row, n_col, n_color)), cmap='<STR_LIT>', interpolation="<STR_LIT>"<EOL>)<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>plt.gca().xaxis.set_major_locator(plt.NullLocator())  <EOL>plt.gca().yaxis.set_major_locator(plt.NullLocator())<EOL>count = count + <NUM_LIT:1><EOL><DEDENT><DEDENT>if saveable:<EOL><INDENT>plt.savefig(name + '<STR_LIT>', format='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>plt.draw()<EOL>plt.pause(second)<EOL><DEDENT>
Display a group of RGB or Greyscale CNN masks.

    Parameters
    ----------
    CNN : numpy.array
        The image. e.g: 64 5x5 RGB images can be (5, 5, 3, 64).
    second : int
        The display second(s) for the image(s), if saveable is False.
    saveable : boolean
        Save or plot the figure.
    name : str
        A name to save the image, if saveable is True.
    fig_idx : int
        The matplotlib figure index.

    Examples
    --------
    >>> tl.visualize.CNN2d(network.all_params[0].eval(), second=10, saveable=True, name='cnn1_mnist', fig_idx=2012)