def model_size(model) -> float:
    """Calculate the number of parameters in a model (in millions).

    :param model: `nn.Module`
    :return: `float`, number of parameters in millions
    """
    return sum(p.numel() for p in model.parameters() if p.requires_grad) / 1000000