code: def buildModelCoeffVarimpCheck(train_data, y, gamX, family):
      numKnots = [5, 6, 7]
      spline_orders = [10, -1, 10]
      x = ["C1", "C2"]
      numPCoeffs = len(train_data["C1"].categories()) + len(
          train_data["C2"].categories()
      )
      numPCoeffs += (
          numKnots[0] + spline_orders[0] - 2
      )  # due to I-spline
      numPCoeffs += numKnots[1] - 1  # due to CS spline
      numPCoeffs += (
          numKnots[2] + spline_orders[2] - 2 - 1
      )  # due to M-splines, minus 1 due to centering
      numPCoeffs += 1  # intercept term
      h2o_model = H2OGeneralizedAdditiveEstimator(
          family=family,
          gam_columns=gamX,
          scale=[1, 1, 1],
          bs=[2, 0, 3],
          spline_orders=[10, -1, 10],
          num_knots=numKnots,
      )
      h2o_model.train(x=x, y=y, training_frame=train_data)
      h2oCoeffs = h2o_model.coef()
  
      assert len(h2oCoeffs) == numPCoeffs, (
          "expected number of coefficients: {0}, actual number of coefficients: "
          "{1}".format(numPCoeffs, len(h2oCoeffs))
      )
      h2oCoeffsStandardized = h2o_model.coef_norm()
      assert len(h2oCoeffsStandardized) == numPCoeffs, (
          "expected number of coefficients: {0}, actual number of "
          "coefficients:{1}".format(
              numPCoeffs, len(h2oCoeffsStandardized)
          )
      )
      varimp = h2o_model.varimp()
      # exclude the intercept term here
      assert len(varimp) == (numPCoeffs - 1), (
          "expected number of coefficients: {0}, actual number of "
          "coefficients:{1}".format(numPCoeffs - 1, len(varimp))
      )
  
imports: from past.utils import old_div
  import sys
  import h2o
  from tests import pyunit_utils
  from h2o.estimators.gam import H2OGeneralizedAdditiveEstimator
label_desc: Use image node_id 2 for calling a global function with example usage: buildModelCoeffVarimpCheck(train_data, y, gamX, family) without return types