def optimize(
        self,
        y,
        test_size,
        n_steps,
        step_size=1,
        seasonal_period=None,
        metric="smape",
        X=None,
        params=None,
    ):
        """
        Optimization method for MFLES

        Parameters
        ----------
        y : np.array
            Your time series as a numpy array.
        test_size : int
            length of the test set to hold out to calculate test error.
        n_steps : int
            number of train and test sets to create.
        step_size : 1, optional
            how many periods to move after each step. The default is 1.
        seasonal_period : int or list, optional
            the seasonal period to calculate for. The default is None.
        metric : TYPE, optional
            supported metrics are smape, mape, mse, mae. The default is 'smape'.
        params : dict, optional
            A user provided dictionary of params to try. The default is None.

        Returns
        -------
        opt_param : TYPE
            DESCRIPTION.

        """
        configs = default_configs(seasonal_period, params)
        # the 4 here is because with less than 4 samples the model defaults to naive
        max_steps = (len(y) - test_size - 4) // step_size + 1
        if max_steps < 1:
            if self.verbose:
                print(
                    "Series does not have enough samples for a single cross validation step "
                    f"({test_size + 4}). Choosing the first configuration."
                )
            return configs[0]
        if max_steps < n_steps:
            n_steps = max_steps
            if self.verbose:
                print(f"Series length too small, setting n_steps to {n_steps}")

        self.metrics = []
        for param in configs:
            cv_results = cross_validation(
                y,
                X,
                test_size,
                n_steps,
                MFLES(verbose=self.verbose),
                step_size=step_size,
                metric=metric,
                **param,
            )
            self.metrics.append(cv_results["metric"])
        return configs[np.argmin(self.metrics)]

        Optimization method for MFLES

        Parameters
        ----------
        y : np.array
            Your time series as a numpy array.
        test_size : int
            length of the test set to hold out to calculate test error.
        n_steps : int
            number of train and test sets to create.
        step_size : 1, optional
            how many periods to move after each step. The default is 1.
        seasonal_period : int or list, optional
            the seasonal period to calculate for. The default is None.
        metric : TYPE, optional
            supported metrics are smape, mape, mse, mae. The default is 'smape'.
        params : dict, optional
            A user provided dictionary of params to try. The default is None.

        Returns
        -------
        opt_param : TYPE
            DESCRIPTION.

        
python/statsforecast/mfles.py