code: def gls_model():
      # Generalized Least Squares (GLS)
      data = get_dataset("longley")
      data.exog = sm.add_constant(data.exog)
      ols_resid = sm.OLS(data.endog, data.exog).fit().resid
      res_fit = sm.OLS(ols_resid[1:], ols_resid[:-1]).fit()
      rho = res_fit.params
      order = toeplitz(np.arange(16))
      sigma = rho**order
      gls = sm.GLS(data.endog, data.exog, sigma=sigma)
      model = gls.fit()
  
      return ModelWithResults(
          model=model, alg=gls, inference_dataframe=data.exog
      )
  
imports: from collections import namedtuple
  import numpy
  import pandas
  import statsmodels.api
  from scipy.linalg import toeplitz
  from statsmodels.tsa.arima.model import ARIMA
  from statsmodels.tsa.arima_process import arma_generate_sample
  from mlflow.models import ModelSignature
  from mlflow.types.schema import Schema, TensorSpec
label_desc: Use image node_id 5 for calling a global function with example usage: gls_model() and returns: ModelWithResults