code: def forecast_arima(
      model,
      h=None,
      level=None,
      fan=False,
      xreg=None,
      blambda=None,
      bootstrap=False,
      npaths=5_000,
      biasadj=None,
  ):
      if h is None:
          h = 2 * model["arma"][4] if model["arma"][4] > 1 else 10
      if blambda is None:
          blambda = model["lambda"]
  
      use_drift = "drift" in model["coef"].keys()
      x = model["x"]
      usexreg = use_drift or (model["xreg"] is not None)
      if (xreg is not None) and usexreg:
          if xreg.dtype not in (np.float32, np.float64):
              raise ValueError("xreg should be a float array")
  
          # origxreg = xreg
          h = xreg.shape[0]
      else:
          if xreg is not None:
              warnings.warn(
                  "xreg not required by this model, ignoring the provided regressors"
              )
              xreg = None
          # origxreg = None
  
      if fan:
          level = np.arange(51, 100, 3)
  
      if use_drift:
          n = len(x)
          drift = np.arange(1, h + 1, dtype=np.float64).reshape(-1, 1)
          drift += n
          if xreg is not None:
              xreg = np.concatenate([drift, xreg], axis=1)
          else:
              xreg = drift
          model["coef"] = change_drift_name(model["coef"], inverse=True)
  
      if is_constant(x):
          pred = np.repeat(x[0], h)
          se = np.repeat(0, h)
      elif usexreg:
          if xreg is None:
              raise Exception("No regressors provided")
          # ncxreg = len([ncoef for ncoef in model['coef'].keys() if 'ex_' in ncoef])
          # if xreg.shape[1] != ncxreg:
          #    raise Exception('Number of regressors does not match fitted model"')
          pred, se = predict_arima(model, n_ahead=h, newxreg=xreg)
          if use_drift:
              model["coef"] = change_drift_name(model["coef"])
      else:
          pred, se = predict_arima(model, n_ahead=h)
  
      if level is not None:
          # nint = len(level)
          if bootstrap:
              raise NotImplementedError("bootstrap=True")
          else:
              quantiles = norm.ppf(0.5 * (1 + np.asarray(level) / 100))
              lower = pd.DataFrame(
                  pred.reshape(-1, 1) - quantiles * se.reshape(-1, 1),
                  columns=[f"{l}%" for l in level],
              )
              upper = pd.DataFrame(
                  pred.reshape(-1, 1) + quantiles * se.reshape(-1, 1),
                  columns=[f"{l}%" for l in level],
              )
      else:
          lower = None
          upper = None
  
      ans = {
          "method": None,
          "model": model,
          "level": None,
          "mean": pred,
          "lower": lower,
          "upper": upper,
          "x": x,
          "series": None,
          "fitted": None,
          "residuals": model["residuals"],
      }
  
      return ans
  
imports: import math
  import warnings
  from collections import namedtuple
  from functools import partial
  from typing import Optional, Dict, Union, Tuple
  import numpy
  import pandas
  import statsmodels.api
  from numba import njit
  from scipy.optimize import minimize
  from scipy.stats import norm
  from .mstl import mstl
  from .utils import CACHE, NOGIL
label_desc: Use image node_id 30 for calling a global function with example usage: forecast_arima(model, h, level, fan, xreg, blambda, bootstrap, npaths, biasadj) and returns: ans