def cnn_params(kernel: int, in_channels: int, out_channels: int, bias: bool = True):
    """
    Return the number of parameters in a CNN.
    Args:
        kernel: Kernel size, it is assumed to be squared.
        in_channels: Number of input channels.
        out_channels: Number of output channels i.e. number of kernels.
        bias: If true count bias as well.
    Returns:
        The number of parameters.
    """
    w = kernel * kernel * in_channels * out_channels
    b = out_channels if bias else 0
    return w + b