code: def pegelsresid_ces(
      y: np.ndarray,
      m: int,
      init_states: np.ndarray,
      n_components: int,
      seasontype: str,
      alpha_0: float,
      alpha_1: float,
      beta_0: float,
      beta_1: float,
      nmse: int,
  ):
      states = np.zeros(
          (len(y) + 2 * m, n_components), dtype=np.float32
      )
      states[:m] = init_states
      e = np.full_like(y, fill_value=np.nan)
      amse = np.full(nmse, fill_value=np.nan)
      lik = cescalc(
          y=y,
          states=states,
          m=m,
          season=switch_ces(seasontype),
          alpha_0=alpha_0,
          alpha_1=alpha_1,
          beta_0=beta_0,
          beta_1=beta_1,
          e=e,
          amse=amse,
          nmse=nmse,
          backfit=1,
      )
      if not np.isnan(lik):
          if np.abs(lik + 99999) < 1e-7:
              lik = np.nan
      return amse, e, states, lik
  
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 8 for calling a global function with example usage: pegelsresid_ces(y, m, init_states, n_components, seasontype, alpha_0, alpha_1, beta_0, beta_1, nmse) and returns: amse,  e,  states,  lik