def out_features(model):
    """Try to extract number of output features from the last layer of a
    model. This is often useful when building encoder-decoder models or
    stacking encoders and classification heads. Not sure how airtight the
    logic is here so use with caution.

    Parameters
    ----------
    model: nn.Module
        Model to examine.

    Returns
    -------
    int: Number of output features.
    """
    return [c.out_features for c in model.children()
            if hasattr(c, 'out_features')][-1]