code: def pegelsresid_C(
      y: np.ndarray,
      m: int,
      init_state: np.ndarray,
      errortype: str,
      trendtype: str,
      seasontype: str,
      damped: bool,
      alpha: float,
      beta: float,
      gamma: float,
      phi: float,
      nmse: int,
  ):
      n = len(y)
      p = len(init_state)
      x = np.full(p * (n + 1), fill_value=np.nan)
      x[:p] = init_state
      e = np.full_like(y, fill_value=np.nan)
      if not damped:
          phi = 1.0
      if trendtype == "N":
          beta = 0.0
      if seasontype == "N":
          gamma = 0.0
      amse = np.full(nmse, fill_value=np.nan)
      lik = etscalc(
          y=y,
          n=n,
          x=x,
          m=m,
          error=switch(errortype),
          trend=switch(trendtype),
          season=switch(seasontype),
          alpha=alpha,
          beta=beta,
          gamma=gamma,
          phi=phi,
          e=e,
          amse=amse,
          nmse=nmse,
      )
      x = x.reshape((n + 1, p))
      if not np.isnan(lik):
          if np.abs(lik + 99999) < 1e-7:
              lik = np.nan
      return amse, e, x, lik
  
imports: import math
  from collections import namedtuple
  from typing import Tuple
  import numpy
  from numba import njit
  from numba.typed import List
  from statsmodels.tsa.seasonal import seasonal_decompose
  from .utils import _calculate_intervals, CACHE, NOGIL
label_desc: Use image node_id 14 for calling a global function with example usage: pegelsresid_C(y, m, init_state, errortype, trendtype, seasontype, damped, alpha, beta, gamma, phi, nmse) and returns: amse,  e,  x,  lik