code: def buildModelCoeffVarimpCheck(train_data, y, gamX, family):
      numKnots = [5, 6, 7]
      x = ["C1", "C2"]
      numPCoeffs = (
          len(train_data["C1"].categories())
          + len(train_data["C2"].categories())
          + sum(numKnots)
          + 1
          - len(numKnots)
      )
      h2o_model = H2OGeneralizedAdditiveEstimator(
          family=family,
          gam_columns=gamX,
          scale=[1, 1, 1],
          num_knots=numKnots,
      )
      h2o_model.train(x=x, y=y, training_frame=train_data)
      h2oCoeffs = h2o_model.coef()
      nclass = 1
      if family == "multinomial":
          nclass = len(train_data[y].categories())
          h2oCoeffs = h2oCoeffs["coefficients"]
  
      assert len(h2oCoeffs) == numPCoeffs * nclass, (
          "expected number of coefficients: {0}, actual number of coefficients: "
          "{1}".format(numPCoeffs * nclass, len(h2oCoeffs))
      )
      h2oCoeffsStandardized = h2o_model.coef_norm()
      if family == "multinomial":
          h2oCoeffsStandardized = h2oCoeffsStandardized[
              "standardized_coefficients"
          ]
      assert len(h2oCoeffsStandardized) == numPCoeffs * nclass, (
          "expected number of coefficients: {0}, actual number of "
          "coefficients:{1}".format(
              numPCoeffs * nclass, 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