Can someone provide guidance on how to implement the MaximumSharpeRatioPortfolioOptimizer?

Example 1: Mean-Variance Portfolio at the link below does not work when tested.

https://www.quantconnect.com/docs/v2/writing-algorithms/historical-data/history-requests

Running a backtest uing the example code results in an error:

Argument 1 to "optimize" of "MaximumSharpeRatioPortfolioOptimizer" has incompatible type "DataFrame"; expected "list[float]"

here is the relevant section of code:

 symbols = self._universe.selected
        history = self.history(symbols, 253, Resolution.DAILY).close.unstack(0).dropna()
        # Daily return on the universe members to calculate the optimized weights.
        returns = history.pct_change().dropna()

        # Calculate the optimized weights.
        weights = self._optimizer.optimize(returns)

here is the funciton definition:

def optimize(historical_returns: typing.List[float], expected_returns: typing.List[float]=None, covariance: typing.List[float]=None) -> typing.List[float]

I tried this revision, but it does not work..

       returns = history.pct_change().dropna().stack().to_numpy().tolist()

How is the optimizer intented to be used?