code: def theta_target_fn(
      optimal_param,
      init_level,
      init_alpha,
      init_theta,
      opt_level,
      opt_alpha,
      opt_theta,
      y,
      modeltype,
      nmse,
  ):
      states = np.zeros((len(y), 5), dtype=np.float32)
      j = 0
      if opt_level:
          level = optimal_param[j]
          j += 1
      else:
          level = init_level
  
      if opt_alpha:
          alpha = optimal_param[j]
          j += 1
      else:
          alpha = init_alpha
  
      if opt_theta:
          theta = optimal_param[j]
          j += 1
      else:
          theta = init_theta
  
      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=level,
          alpha=alpha,
          theta=theta,
          e=e,
          amse=amse,
          nmse=nmse,
      )
      if mse < -1e10:
          mse = -1e10
      if math.isnan(mse):
          mse = -np.inf
      if math.fabs(mse + 99999) < 1e-7:
          mse = -np.inf
      return 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 9 for calling a global function with example usage: theta_target_fn(optimal_param, init_level, init_alpha, init_theta, opt_level, opt_alpha, opt_theta, y, modeltype, nmse) and returns: mse