code: def Arima(
      x,
      order=(0, 0, 0),
      seasonal={"order": (0, 0, 0), "period": 1},
      xreg=None,
      include_mean=True,
      include_drift=False,
      include_constant=None,
      blambda=None,
      biasadj=False,
      method="CSS",
      model=None,
      **kwargs,
  ):
      x = x.copy()
      origx = x.copy()
      seas_order = seasonal["order"]
      if blambda is not None:
          raise NotImplementedError("blambda != None")
          # x = boxcox(x, blambda)
          # if not hasattr(blambda, 'biasadj'):
          #    setattr(blambda, 'biasadj', biasadj)
      if xreg is not None:
          if xreg.dtype not in (np.float32, np.float64):
              raise ValueError("xreg should be a float array")
      if len(x) <= order[1]:
          raise ValueError("Not enough data to fit the model")
      if len(x) <= order[1] + seas_order[1] * seasonal["period"]:
          raise ValueError("Not enough data to fit the model")
      if include_constant is not None:
          if include_constant:
              include_mean = True
              if order[1] + seas_order[1] == 1:
                  include_drift = True
          else:
              include_mean = include_drift = False
      if order[1] + seas_order[1] > 1 and include_drift:
          warnings.warn(
              "No drift term fitted as the order of difference is 2 or more."
          )
          include_drift = False
      if model is not None:
          tmp = arima2(x=x, model=model, xreg=xreg, method=method)
          xreg = tmp["xreg"]
          tmp["lambda"] = model["lambda"]
      else:
          if include_drift:
              drift = np.arange(
                  1, x.size + 1, dtype=np.float64
              ).reshape(
                  -1, 1
              )  # drift
              if xreg is not None:
                  xreg = np.concatenate([drift, xreg], axis=1)
              else:
                  xreg = drift
              if "fixed" in kwargs:
                  if isinstance(kwargs["fixed"], dict):
                      if "drift" not in kwargs["fixed"]:
                          kwargs["fixed"]["drift"] = np.nan
                      kwargs["fixed"] = change_drift_name(
                          kwargs["fixed"], inverse=True
                      )
          if xreg is None:
              tmp = arima(
                  x,
                  order=order,
                  seasonal=seasonal,
                  include_mean=include_mean,
                  method=method,
                  **kwargs,
              )
          else:
              tmp = arima(
                  x,
                  order=order,
                  seasonal=seasonal,
                  xreg=xreg,
                  include_mean=include_mean,
                  method=method,
                  **kwargs,
              )
              if include_drift:
                  tmp["coef"] = change_drift_name(tmp["coef"])
  
      npar = np.sum(tmp["mask"]) + 1
      missing = np.isnan(tmp["residuals"])
      nonmiss_idxs = np.where(~missing)[0]
      firstnonmiss = np.min(nonmiss_idxs)
      lastnonmiss = np.max(nonmiss_idxs) + 1
      n = np.sum(~missing[firstnonmiss:lastnonmiss])
      nstar = n - tmp["arma"][5] - tmp["arma"][6] * tmp["arma"][4]
      tmp["aicc"] = tmp["aic"] + 2 * npar * (
          nstar / (nstar - npar - 1) - 1
      )
      tmp["bic"] = tmp["aic"] + npar * (math.log(nstar) - 2)
      tmp["xreg"] = xreg
      tmp["lambda"] = blambda
      tmp["x"] = origx
      if model is None:
          tmp["sigma2"] = np.nansum(tmp["residuals"] ** 2) / (
              nstar - npar + 1
          )
      return tmp
  
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 27 for calling a global function with example usage: Arima(x, order, seasonal, xreg, include_mean, include_drift, include_constant, blambda, biasadj, method, model) and returns: tmp