code: def pegelsresid_theta(
      y: np.ndarray,
      modeltype: str,
      initial_smoothed: float,
      alpha: float,
      theta: float,
      nmse: int,
  ):
      states = np.zeros((len(y), 5), dtype=np.float32)
      e = np.full_like(y, fill_value=np.nan)
      amse = np.full(nmse, fill_value=np.nan)
      mse = thetacalc(
          y=y,
          states=states,
          modeltype=switch_theta(modeltype),
          initial_smoothed=initial_smoothed,
          alpha=alpha,
          theta=theta,
          e=e,
          amse=amse,
          nmse=nmse,
      )
      if not np.isnan(mse):
          if np.abs(mse + 99999) < 1e-7:
              mse = np.nan
      return amse, e, states, mse
  
imports: import math
  from typing import Tuple
  import numpy
  from numba import njit
  from scipy.stats import norm
  from statsmodels.tsa.seasonal import seasonal_decompose
  from statsmodels.tsa.stattools import acf
  from .ets import restrict_to_bounds, results
  from .utils import _seasonal_naive, _repeat_val_seas, CACHE, NOGIL
label_desc: Use image node_id 8 for calling a global function with example usage: pegelsresid_theta(y, modeltype, initial_smoothed, alpha, theta, nmse) and returns: amse,  e,  states,  mse