<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def returns_annualized(returns, geometric=True, scale=None, expanding=False):
 """ return the annualized cumulative returns Parameters returns : DataFrame or Series geometric : link the returns geometrically scale: None or scalar or string (ie 12 for months in year), If None, attempt to resolve from returns If scalar, then use this as the annualization factor If string, then pass this to periodicity function to resolve annualization factor expanding: bool, default is False If True, return expanding series/frames. If False, return final result. """

    scale = _resolve_periods_in_year(scale, returns)
    if expanding:
        if geometric:
            n = pd.expanding_count(returns)
            return ((1. + returns).cumprod() ** (scale / n)) - 1.
        else:
            return pd.expanding_mean(returns) * scale
    else:
        if geometric:
            n = returns.count()
            return ((1. + returns).prod() ** (scale / n)) - 1.
        else:
            return returns.mean() * scale