code: def _seasonal_prediction_with_confidence(
      arima_res,
      start,
      end,
      X,
      alpha,
      **kwargs,
  ):
      """Compute the prediction for a SARIMAX and get a conf interval
  
      Unfortunately, SARIMAX does not really provide a nice way to get the
      confidence intervals out of the box, so we have to perform the
      ``get_prediction`` code here and unpack the confidence intervals manually.
  
      Notes
      -----
      For internal use only.
      """
      results = arima_res.get_prediction(
          start=start, end=end, exog=X, **kwargs
      )
  
      f = results.predicted_mean
      conf_int = results.conf_int(alpha=alpha)
      if arima_res.specification["simple_differencing"]:
          # If simple_differencing == True, statsmodels.get_prediction returns
          # mid and confidence intervals on differenced time series.
          # We have to invert differencing the mid and confidence intervals
          y_org = arima_res.model.orig_endog
          d = arima_res.model.orig_k_diff
          D = arima_res.model.orig_k_seasonal_diff
          period = arima_res.model.seasonal_periods
          # Forecast mid: undifferencing non-seasonal part
          if d > 0:
              y_sdiff = y_org if D == 0 else diff(y_org, period, D)
              f_temp = np.append(y_sdiff[-d:], f)
              f_temp = diff_inv(f_temp, 1, d)
              f = f_temp[(2 * d) :]
          # Forecast mid: undifferencing seasonal part
          if D > 0 and period > 1:
              f_temp = np.append(y_org[-(D * period) :], f)
              f_temp = diff_inv(f_temp, period, D)
              f = f_temp[(2 * D * period) :]
          # confidence interval
          ar_poly = arima_res.polynomial_reduced_ar
          poly_diff = np_polynomial.polypow(np.array([1.0, -1.0]), d)
          sdiff = np.zeros(period + 1)
          sdiff[0] = 1.0
          sdiff[-1] = 1.0
          poly_sdiff = np_polynomial.polypow(sdiff, D)
          ar = -np.polymul(ar_poly, np.polymul(poly_diff, poly_sdiff))[
              1:
          ]
          ma = arima_res.polynomial_reduced_ma[1:]
          n_predMinus1 = end - start
          ema = ARMAtoMA(ar, ma, n_predMinus1)
          sigma2 = arima_res._params_variance[0]
          var = np.cumsum(np.append(1.0, ema * ema)) * sigma2
          q = results.dist.ppf(1.0 - alpha / 2, *results.dist_args)
          conf_int[:, 0] = f - q * np.sqrt(var)
          conf_int[:, 1] = f + q * np.sqrt(var)
  
      y_pred = check_endog(
          f, dtype=None, copy=False, preserve_series=True
      )
      conf_int = check_array(conf_int, copy=False, dtype=None)
  
      return y_pred, conf_int
  
imports: import pandas
  import numpy
  import numpy.polynomial.polynomial
  import numbers
  import warnings
  from scipy.stats import gaussian_kde, norm
  from sklearn.utils.validation import check_array
  from statsmodels import api
  from .None import _validation
  from ..base import BaseARIMA
  from ..compat.numpy import DTYPE
  from ..compat.sklearn import check_is_fitted, if_delegate_has_method, safe_indexing
  from ..compat import statsmodels
  from ..compat import matplotlib
  from ..utils import if_has_delegate, is_iterable, check_endog, check_exog
  from ..utils.visualization import _get_plt
  from ..utils.array import diff_inv, diff
  import pmdarima
label_desc: Use image node_id 4 for calling a global function with example usage: _seasonal_prediction_with_confidence(arima_res, start, end, X, alpha) and returns: y_pred,  conf_int