code: def infer_mixed_family_and_dist_helper(
      family,
      expected_family,
      first_glm,
      expected_link=None,
      kwargs_glm=None,
      kwargs_gbm=None,
      metalearner_params=None,
  ):
      kwargs_glm = dict() if kwargs_glm is None else kwargs_glm
      kwargs_gbm = dict() if kwargs_gbm is None else kwargs_gbm
      metalearner_params = (
          dict() if metalearner_params is None else metalearner_params
      )
  
      distribution = family if not family == "binomial" else "bernoulli"
      expected_distribution = (
          expected_family
          if not expected_family == "binomial"
          else "bernoulli"
      )
  
      train = h2o.import_file(
          pyunit_utils.locate("smalldata/iris/iris_train.csv")
      )
      test = h2o.import_file(
          pyunit_utils.locate("smalldata/iris/iris_test.csv")
      )
      if family == "multinomial":
          y = "species"
      elif family == "binomial":
          train["response"] = (
              train["species"] == "Iris-versicolor"
          ).asfactor()
          test["response"] = (
              test["species"] == "Iris-versicolor"
          ).asfactor()
          y = "response"
      elif family == "quasibinomial" or family == "fractionalbinomial":
          train["response"] = (
              train["species"] == "Iris-versicolor"
          ) / 2
          test["response"] = (test["species"] == "Iris-versicolor") / 2
          y = "response"
      elif family == "ordinal":
          y = "response"
          train[y] = train["species"] == "Iris-versicolor"
          test[y] = test["species"] == "Iris-versicolor"
          train[(train["species"] == "Iris-setosa"), y] = 2
          test[(test["species"] == "Iris-setosa"), y] = 2
          train[y] = train[y].asfactor()
          test[y] = test[y].asfactor()
      else:
          y = "petal_wid"
  
      x = train.columns
      x.remove(y)
  
      if "family" not in kwargs_glm:
          kwargs_glm["family"] = family
  
      if "distribution" not in kwargs_gbm:
          kwargs_gbm["distribution"] = distribution
  
      nfolds = 2
      glm = H2OGeneralizedLinearEstimator(
          nfolds=nfolds,
          fold_assignment="Modulo",
          keep_cross_validation_predictions=True,
          **kwargs_glm,
      )
      glm.train(x=x, y=y, training_frame=train)
  
      gbm = H2OGradientBoostingEstimator(
          nfolds=nfolds,
          fold_assignment="Modulo",
          keep_cross_validation_predictions=True,
          **kwargs_gbm,
      )
      gbm.train(x=x, y=y, training_frame=train)
  
      se = H2OStackedEnsembleEstimator(
          training_frame=train,
          validation_frame=test,
          base_models=[glm, gbm] if first_glm else [gbm, glm],
          metalearner_algorithm="glm",
          metalearner_params={
              k: v
              for k, v in metalearner_params.items()
              if k != "distribution"
          },
      )
      se.train(x, y, train)
      assert (
          se.metalearner().actual_params.get("family")
          == expected_family
      ), "Expected family {} but got {}".format(
          expected_family, se.metalearner().actual_params.get("family")
      )
      if expected_link:
          assert (
              se.metalearner().actual_params.get("link")
              == expected_link
          ), "Expected link {} but got {}".format(
              expected_link, se.metalearner().actual_params.get("link")
          )
  
      se_auto = H2OStackedEnsembleEstimator(
          training_frame=train,
          validation_frame=test,
          base_models=[glm, gbm] if first_glm else [gbm, glm],
          metalearner_algorithm="auto",
          metalearner_params={
              k: v
              for k, v in metalearner_params.items()
              if k != "distribution"
          },
      )
      se_auto.train(x, y, train)
      assert (
          se_auto.metalearner().actual_params.get("family")
          == expected_family
      ), "Expected family {} but got {}".format(
          expected_family,
          se_auto.metalearner().actual_params.get("family"),
      )
      if expected_link:
          assert (
              se_auto.metalearner().actual_params.get("link")
              == expected_link
          ), "Expected link {} but got {}".format(
              expected_link,
              se_auto.metalearner().actual_params.get("link"),
          )
      se_gbm = H2OStackedEnsembleEstimator(
          training_frame=train,
          validation_frame=test,
          base_models=[glm, gbm] if first_glm else [gbm, glm],
          metalearner_algorithm="gbm",
          metalearner_params={
              k: v
              for k, v in metalearner_params.items()
              if k != "family" and k != "link"
          },
      )
      se_gbm.train(x, y, train)
      assert (
          se_gbm.metalearner().actual_params.get("distribution")
          == expected_distribution
      ), "Expected distribution {} but got {}".format(
          expected_distribution,
          se_gbm.metalearner().actual_params.get("distribution"),
      )
  
file_path: h2o-3/h2o-py/tests/testdir_algos/stackedensemble/pyunit_stackedensemble_distributions.py
imports: import sys
  import h2o
  from h2o.estimators.random_forest import H2ORandomForestEstimator
  from h2o.estimators.glm import H2OGeneralizedLinearEstimator
  from h2o.estimators.gbm import H2OGradientBoostingEstimator
  from h2o.estimators.stackedensemble import H2OStackedEnsembleEstimator
  from h2o.estimators.naive_bayes import H2ONaiveBayesEstimator
  from tests import pyunit_utils
label_desc: Use image node_id 5 for calling a global function with example usage: infer_mixed_family_and_dist_helper(family, expected_family, first_glm, expected_link, kwargs_glm, kwargs_gbm, metalearner_params) without return types