def fitted_arima(model, h=1):
    """Returns h-step forecasts for the data used in fitting the model."""
    if h == 1:
        x = model.get("x")
        if model.get("fitted") is not None:
            return model.get("fitted")
        elif x is None:
            return None
        elif model.get("lambda") is None:
            return x - model["residuals"]
        else:
            raise NotImplementedError("lambda not None")
    else:
        raise NotImplementedError("h > 1")
Returns h-step forecasts for the data used in fitting the model.
python/statsforecast/arima.py