def print_network(net, out_f=None):
    """
    Prints the number of learnable parameters.

    :param net: the network.
    :type net:
    :param out_f: file
    :type out_f:
    :return: number of learnable parameters.
    :rtype: int
    """
    num_params = 0
    for param in net.parameters():
        num_params += param.numel()

    if out_f is not None:
        out_f.write(net.__repr__() + "\n")
        out_f.write('Total number of parameters: %d\n' % num_params)
        out_f.flush()
    return num_params