code: def test_approximation():
      np.random.seed(1)
      poly, y = polynomial_sample_data()
      alpha = 1
      for _ in range(10):
          params = np.random.uniform(-1, 1, 4)
          cost, err, itg = cost_function(params, poly, y, alpha)
          glm_gam = GLMGam(y, smoother=poly, alpha=alpha)
          # TODO: why do we need pen_weight=1
          gam_loglike = glm_gam.loglike(params, scale=1, pen_weight=1)
          assert_allclose(err - itg, cost, rtol=1e-10)
          assert_allclose(gam_loglike, cost, rtol=0.1)
  
imports: import os
  import numpy
  from numpy.testing import assert_allclose
  import pandas
  from scipy.linalg import block_diag
  import pytest
  from statsmodels.tools.linalg import matrix_sqrt
  from statsmodels.gam.smooth_basis import UnivariatePolynomialSmoother, PolynomialSmoother, BSplines, GenericSmoothers, UnivariateCubicSplines, CyclicCubicSplines
  from statsmodels.gam.generalized_additive_model import GLMGam, LogitGam, make_augmented_matrix, penalized_wls
  from statsmodels.gam.gam_cross_validation.gam_cross_validation import MultivariateGAMCV, MultivariateGAMCVPath, _split_train_test_smoothers
  from statsmodels.gam.gam_penalties import UnivariateGamPenalty, MultivariateGamPenalty
  from statsmodels.gam.gam_cross_validation.cross_validators import KFold
  from statsmodels.genmod.generalized_linear_model import GLM
  from statsmodels.genmod.families.family import Gaussian
  from statsmodels.genmod.generalized_linear_model import lm
label_desc: Use image node_id 9 for calling a global function with example usage: test_approximation() without return types