code: def _class3models(
      h,
      sigma,
      last_state,
      season_length,
      error,
      trend,
      seasonality,
      damped,
      alpha,
      beta,
      gamma,
      phi,
  ):
      if damped == "N":
          damped_val = False
      else:
          damped_val = True
  
      p = len(last_state)
  
      if trend != "N":
          H1 = np.array([[1, 1]])
      else:
          H1 = np.array([[1]])
  
      H2 = np.concatenate(
          (np.zeros(season_length - 1), np.array([1]))
      ).reshape(1, season_length)
  
      if trend == "N":
          F1 = 1
          G1 = alpha
      else:
          f1 = 1
          if damped_val:
              f1 = phi
          F1 = np.array([[1, 1], [0, f1]])
          G1 = np.array([[alpha, alpha], [beta, beta]])
  
      f2_top = np.concatenate(
          (np.zeros(season_length - 1), np.array([1]))
      ).reshape(1, season_length)
      f2_bottom = np.c_[
          (
              np.identity(season_length - 1),
              np.zeros(season_length - 1).reshape(season_length - 1, 1),
          )
      ]
      F2 = np.r_[f2_top, f2_bottom]
  
      G2 = np.zeros((season_length, season_length))
      G2[0, season_length - 1] = gamma
      Mh = np.matmul(
          last_state[0 : (p - season_length)].reshape(
              last_state[0 : (p - season_length)].shape[0], 1
          ),
          last_state[(p - season_length) : p].reshape(1, season_length),
      )
      Vh = np.zeros(
          (Mh.shape[0] * Mh.shape[1], Mh.shape[0] * Mh.shape[1])
      )
      H21 = np.kron(H2, H1)
      F21 = np.kron(F2, F1)
      G21 = np.kron(G2, G1)
      K = np.kron(G2, F1) + np.kron(F2, G1)
      mu = np.zeros(h)
      var = np.zeros(h)
  
      for i in range(0, h):
          mu[i] = np.matmul(H1, np.matmul(Mh, np.transpose(H2)))
          var[i] = (1 + sigma) * np.matmul(
              H21, np.matmul(Vh, np.transpose(H21))
          ) + sigma * mu[i] ** 2
          vecMh = Mh.flatten()
          exp1 = np.matmul(F21, np.matmul(Vh, np.transpose(F21)))
          exp2 = np.matmul(F21, np.matmul(Vh, np.transpose(G21)))
          exp3 = np.matmul(G21, np.matmul(Vh, np.transpose(F21)))
          exp4 = np.matmul(
              K,
              np.matmul(
                  Vh + (vecMh * vecMh.reshape(vecMh.shape[0], 1)),
                  np.transpose(K),
              ),
          )
          exp5 = np.matmul(
              sigma * G21,
              np.matmul(
                  3 * Vh + 2 * vecMh * vecMh.reshape(vecMh.shape[0], 1),
                  np.transpose(G21),
              ),
          )
          Vh = exp1 + sigma * (exp2 + exp3 + exp4 + exp5)
  
      if trend == "N":
          Mh = (
              F1 * np.matmul(Mh, np.transpose(F2))
              + G1 * np.matmul(Mh, np.transpose(G2)) * sigma
          )
      else:
          Mh = (
              np.matmul(F1, np.matmul(Mh, np.transpose(F2)))
              + np.matmul(G1, np.matmul(Mh, np.transpose(G2))) * sigma
          )
  
      return var
  
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 24 for calling a global function with example usage: _class3models(h, sigma, last_state, season_length, error, trend, seasonality, damped, alpha, beta, gamma, phi) and returns: var