def drop(x, keep=<NUM_LIT:0.5>):
if len(x.shape) == <NUM_LIT:3>:<EOL><INDENT>if x.shape[-<NUM_LIT:1>] == <NUM_LIT:3>:  <EOL><INDENT>img_size = x.shape<EOL>mask = np.random.binomial(n=<NUM_LIT:1>, p=keep, size=x.shape[:-<NUM_LIT:1>])<EOL>for i in range(<NUM_LIT:3>):<EOL><INDENT>x[:, :, i] = np.multiply(x[:, :, i], mask)<EOL><DEDENT><DEDENT>elif x.shape[-<NUM_LIT:1>] == <NUM_LIT:1>:  <EOL><INDENT>img_size = x.shape<EOL>x = np.multiply(x, np.random.binomial(n=<NUM_LIT:1>, p=keep, size=img_size))<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>".format(x.shape))<EOL><DEDENT><DEDENT>elif len(x.shape) == <NUM_LIT:2> or <NUM_LIT:1>:  <EOL><INDENT>img_size = x.shape<EOL>x = np.multiply(x, np.random.binomial(n=<NUM_LIT:1>, p=keep, size=img_size))<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>".format(x.shape))<EOL><DEDENT>return x<EOL>
Randomly set some pixels to zero by a given keeping probability.

    Parameters
    -----------
    x : numpy.array
        An image with dimension of [row, col, channel] or [row, col].
    keep : float
        The keeping probability (0, 1), the lower more values will be set to zero.

    Returns
    -------
    numpy.array
        A processed image.