code: def cesmodel(
      y: np.ndarray,
      m: int,
      seasontype: str,
      alpha_0: float,
      alpha_1: float,
      beta_0: float,
      beta_1: float,
      nmse: int,
  ):
      if seasontype == "N":
          m = 1
      # initial parameters
      par = initparamces(
          alpha_0=alpha_0,
          alpha_1=alpha_1,
          beta_1=beta_1,
          beta_0=beta_0,
          seasontype=seasontype,
      )
      optimize_params = {
          key.replace("optimize_", ""): val
          for key, val in par.items()
          if "optim" in key
      }
      par = {key: val for key, val in par.items() if "optim" not in key}
      # initial states
      init_state = initstate(y, m, seasontype)
      n_components = init_state.shape[1]
      # parameter optimization
      fred = optimize_ces_target_fn(
          init_par=par,
          optimize_params=optimize_params,
          y=y,
          m=m,
          init_states=init_state,
          n_components=n_components,
          seasontype=seasontype,
          nmse=nmse,
      )
      if fred is not None:
          fit_par = fred.x
      j = 0
      if optimize_params["alpha_0"]:
          par["alpha_0"] = fit_par[j]
          j += 1
      if optimize_params["alpha_1"]:
          par["alpha_1"] = fit_par[j]
          j += 1
      if optimize_params["beta_0"]:
          par["beta_0"] = fit_par[j]
          j += 1
      if optimize_params["beta_1"]:
          par["beta_1"] = fit_par[j]
          j += 1
  
      amse, e, states, lik = pegelsresid_ces(
          y=y,
          m=m,
          init_states=init_state,
          n_components=n_components,
          seasontype=seasontype,
          nmse=nmse,
          **par,
      )
      np_ = n_components + 1
      ny = len(y)
      aic = lik + 2 * np_
      bic = lik + np.log(ny) * np_
      if ny - np_ - 1 != 0.0:
          aicc = aic + 2 * np_ * (np_ + 1) / (ny - np_ - 1)
      else:
          aicc = np.inf
  
      mse = amse[0]
      amse = np.mean(amse)
  
      fitted = y - e
      sigma2 = np.sum(e**2) / (ny - np_ - 1)
  
      return dict(
          loglik=-0.5 * lik,
          aic=aic,
          bic=bic,
          aicc=aicc,
          mse=mse,
          amse=amse,
          fit=fred,
          fitted=fitted,
          residuals=e,
          m=m,
          states=states,
          par=par,
          n=len(y),
          seasontype=seasontype,
          sigma2=sigma2,
      )
  
imports: import math
  from typing import Tuple
  import numpy
  from numba import njit
  from statsmodels.tsa.seasonal import seasonal_decompose
  from .ets import restrict_to_bounds, results
  from .utils import CACHE, NOGIL
label_desc: Use image node_id 12 for calling a global function with example usage: cesmodel(y, m, seasontype, alpha_0, alpha_1, beta_0, beta_1, nmse) and returns: dict