code: def thetamodel(
      y: np.ndarray,
      m: int,
      modeltype: str,
      initial_smoothed: float,
      alpha: float,
      theta: float,
      nmse: int,
  ):
      # initial parameters
      par = initparamtheta(
          initial_smoothed=initial_smoothed,
          alpha=alpha,
          theta=theta,
          y=y,
          modeltype=modeltype,
      )
      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}
      # parameter optimization
      fred = optimize_theta_target_fn(
          init_par=par,
          optimize_params=optimize_params,
          y=y,
          modeltype=modeltype,
          nmse=nmse,
      )
      if fred is not None:
          fit_par = fred.x
      j = 0
      if optimize_params["initial_smoothed"]:
          j += 1
      if optimize_params["alpha"]:
          par["alpha"] = fit_par[j]
          j += 1
      if optimize_params["theta"]:
          par["theta"] = fit_par[j]
          j += 1
  
      amse, e, states, mse = pegelsresid_theta(
          y=y, modeltype=modeltype, nmse=nmse, **par
      )
  
      return dict(
          mse=mse,
          amse=amse,
          fit=fred,
          residuals=e,
          m=m,
          states=states,
          par=par,
          n=len(y),
          modeltype=modeltype,
          mean_y=np.mean(y),
      )
  
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 13 for calling a global function with example usage: thetamodel(y, m, modeltype, initial_smoothed, alpha, theta, nmse) and returns: dict