code: def test_glm_pirls_compatibility():
      np.random.seed(0)
  
      n = 500
      x1 = np.linspace(-3, 3, n)
      x2 = np.random.rand(n)
  
      x = np.vstack([x1, x2]).T
      y1 = np.sin(x1) / x1
      y2 = x2 * x2
      y0 = y1 + y2
      y = y0 + np.random.normal(0, 0.3, n)
      y -= y.mean()
      y0 -= y0.mean()
  
      # TODO: we have now alphas == alphas_glm
      alphas = [5.75] * 2
      alphas_glm = [1.2] * 2  # noqa: F841
      # using constraints avoids singular exog.
      cs = BSplines(x, df=[10, 10], degree=[3, 3], constraints="center")
  
      gam_pirls = GLMGam(y, smoother=cs, alpha=alphas)
      gam_glm = GLMGam(y, smoother=cs, alpha=alphas)
  
      gam_res_glm = gam_glm.fit(
          method="nm", max_start_irls=0, disp=1, maxiter=20000
      )
      gam_res_glm = gam_glm.fit(
          start_params=gam_res_glm.params,
          method="bfgs",
          max_start_irls=0,
          disp=1,
          maxiter=20000,
      )
      gam_res_pirls = gam_pirls.fit()
  
      y_est_glm = np.dot(cs.basis, gam_res_glm.params)
      y_est_glm -= y_est_glm.mean()
      y_est_pirls = np.dot(cs.basis, gam_res_pirls.params)
      y_est_pirls -= y_est_pirls.mean()
  
      # plt.plot(y_est_pirls)
      # plt.plot(y_est_glm)
      # plt.plot(y, '.')
      # plt.show()
      assert_allclose(
          gam_res_glm.params, gam_res_pirls.params, atol=5e-5, rtol=5e-5
      )
      assert_allclose(y_est_glm, y_est_pirls, atol=5e-5)
  
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 24 for calling a global function with example usage: test_glm_pirls_compatibility() without return types