<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sortino_ratio(returns, required_return=0, period=DAILY, annualization=None, out=None, _downside_risk=None):
 """ Determines the Sortino ratio of a strategy. Parameters returns : pd.Series or np.ndarray or pd.DataFrame Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. required_return: float / series minimum acceptable return period : str, optional Defines the periodicity of the 'returns' data for purposes of annualizing. Value ignored if `annualization` parameter is specified. Defaults are:: 'monthly':12 'weekly': 52 'daily': 252 annualization : int, optional Used to suppress default values available in `period` to convert returns into annual returns. Value should be the annual frequency of `returns`. _downside_risk : float, optional The downside risk of the given inputs, if known. Will be calculated if not provided. out : array-like, optional Array to use as output buffer. If not passed, a new array will be created. Returns ------- sortino_ratio : float or pd.Series depends on input type series ==> float DataFrame ==> pd.Series Note ----- See `<https://www.sunrisecapital.com/wp-content/uploads/2014/06/Futures_ Mag_Sortino_0213.pdf>`__ for more details. """

    allocated_output = out is None
    if allocated_output:
        out = np.empty(returns.shape[1:])

    return_1d = returns.ndim == 1

    if len(returns) < 2:
        out[()] = np.nan
        if return_1d:
            out = out.item()
        return out

    adj_returns = np.asanyarray(_adjust_returns(returns, required_return))

    ann_factor = annualization_factor(period, annualization)

    average_annual_return = nanmean(adj_returns, axis=0) * ann_factor
    annualized_downside_risk = (
        _downside_risk
        if _downside_risk is not None else
        downside_risk(returns, required_return, period, annualization)
    )
    np.divide(average_annual_return, annualized_downside_risk, out=out)
    if return_1d:
        out = out.item()
    elif isinstance(returns, pd.DataFrame):
        out = pd.Series(out)

    return out