def count_params(net, exclude=[]):
    """
    Count parameters for net.
    :param net: mxnet.gluon.Block
        Net or block to be counted parameters for.
    :param exclude: list of mxnet.gluon.nn.Block
        Blocks to be excluded.
    :return: int
        The number of parameters of net.
    """
    exclude_params = []
    for exc in exclude:
        exclude_params.extend(list(exc.collect_params()))

    params_counter = 0
    params = net.collect_params()
    for p in params:
        if p not in exclude_params:
            params_counter += params[p].data().size
    return params_counter