def count_parameters(model):
    """
    Compute the number of trainable parameters of the model.
    :param model: type nn.Module
    :return: number of parameters, type int
    """
    return sum(p.numel() for p in model.parameters() if p.requires_grad)