code: def class_extensions():
      def metalearner(self):
          """Print the metalearner of an H2OStackedEnsembleEstimator.
  
          :examples:
  
          >>> from h2o.estimators.random_forest import H2ORandomForestEstimator
          >>> from h2o.estimators.gbm import H2OGradientBoostingEstimator
          >>> from h2o.estimators.stackedensemble import H2OStackedEnsembleEstimator
          >>> higgs = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/testng/higgs_train_5k.csv")
          >>> train, blend = higgs.split_frame(ratios = [.8], seed = 1234)
          >>> x = train.columns
          >>> y = "response"
          >>> x.remove(y)
          >>> train[y] = train[y].asfactor()
          >>> blend[y] = blend[y].asfactor()
          >>> nfolds = 3
          >>> my_gbm = H2OGradientBoostingEstimator(distribution="bernoulli",
          ...                                       ntrees=10,
          ...                                       nfolds=nfolds,
          ...                                       fold_assignment="Modulo",
          ...                                       keep_cross_validation_predictions=True,
          ...                                       seed=1)
          >>> my_gbm.train(x=x, y=y, training_frame=train)
          >>> my_rf = H2ORandomForestEstimator(ntrees=50,
          ...                                  nfolds=nfolds,
          ...                                  fold_assignment="Modulo",
          ...                                  keep_cross_validation_predictions=True,
          ...                                  seed=1)
          >>> my_rf.train(x=x, y=y, training_frame=train)
          >>> stack_blend = H2OStackedEnsembleEstimator(base_models=[my_gbm, my_rf],
          ...                                           seed=1,
          ...                                           keep_levelone_frame=True)
          >>> stack_blend.train(x=x, y=y, training_frame=train, blending_frame=blend)
          >>> stack_blend.metalearner()
          """
  
          def _get_item(self, key):
              warnings.warn(
                  "The usage of stacked_ensemble.metalearner()['name'] will be deprecated. "
                  "Metalearner now returns the metalearner object. If you need to get the "
                  "'name' please use stacked_ensemble.metalearner().model_id",
                  H2ODeprecationWarning,
              )
              if key == "name":
                  return self.model_id
              raise NotImplementedError
  
          model = self._model_json["output"]
          if (
              "metalearner" in model
              and model["metalearner"] is not None
          ):
              metalearner = h2o.get_model(model["metalearner"]["name"])
              metalearner.__class__.__getitem__ = _get_item
              return metalearner
          print("No metalearner for this model")
  
      def levelone_frame_id(self):
          """Fetch the levelone_frame_id for an H2OStackedEnsembleEstimator.
  
          :examples:
  
          >>> from h2o.estimators.random_forest import H2ORandomForestEstimator
          >>> from h2o.estimators.gbm import H2OGradientBoostingEstimator
          >>> from h2o.estimators.stackedensemble import H2OStackedEnsembleEstimator
          >>> higgs = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/testng/higgs_train_5k.csv")
          >>> train, blend = higgs.split_frame(ratios = [.8], seed = 1234)
          >>> x = train.columns
          >>> y = "response"
          >>> x.remove(y)
          >>> train[y] = train[y].asfactor()
          >>> blend[y] = blend[y].asfactor()
          >>> nfolds = 3
          >>> my_gbm = H2OGradientBoostingEstimator(distribution="bernoulli",
          ...                                       ntrees=10,
          ...                                       nfolds=nfolds,
          ...                                       fold_assignment="Modulo",
          ...                                       keep_cross_validation_predictions=True,
          ...                                       seed=1)
          >>> my_gbm.train(x=x, y=y, training_frame=train)
          >>> my_rf = H2ORandomForestEstimator(ntrees=50,
          ...                                  nfolds=nfolds,
          ...                                  fold_assignment="Modulo",
          ...                                  keep_cross_validation_predictions=True,
          ...                                  seed=1)
          >>> my_rf.train(x=x, y=y, training_frame=train)
          >>> stack_blend = H2OStackedEnsembleEstimator(base_models=[my_gbm, my_rf],
          ...                                           seed=1,
          ...                                           keep_levelone_frame=True)
          >>> stack_blend.train(x=x, y=y, training_frame=train, blending_frame=blend)
          >>> stack_blend.levelone_frame_id()
          """
          model = self._model_json["output"]
          if (
              "levelone_frame_id" in model
              and model["levelone_frame_id"] is not None
          ):
              return model["levelone_frame_id"]
          print("No levelone_frame_id for this model")
  
      def stacking_strategy(self):
          model = self._model_json["output"]
          if (
              "stacking_strategy" in model
              and model["stacking_strategy"] is not None
          ):
              return model["stacking_strategy"]
          print("No stacking strategy for this model")
  
      # Override train method to support blending
      def train(
          self,
          x=None,
          y=None,
          training_frame=None,
          blending_frame=None,
          verbose=False,
          **kwargs,
      ):
          has_training_frame = (
              training_frame is not None
              or self.training_frame is not None
          )
          blending_frame = H2OFrame._validate(
              blending_frame,
              "blending_frame",
              required=not has_training_frame,
          )
  
          if not has_training_frame:
              training_frame = blending_frame  # used to bypass default checks in super class and backend and to guarantee default metrics
  
          sup = super(self.__class__, self)
  
          def extend_parms(parms):
              if blending_frame is not None:
                  parms["blending_frame"] = blending_frame
              if self.metalearner_fold_column is not None:
                  parms["ignored_columns"].remove(
                      quoted(self.metalearner_fold_column)
                  )
  
          parms = sup._make_parms(
              x,
              y,
              training_frame,
              extend_parms_fn=extend_parms,
              **kwargs,
          )
  
          sup._train(parms, verbose=verbose)
          if self.metalearner() is None:
              raise H2OResponseError(
                  "Meta learner didn't get to be trained in time. "
                  "Try increasing max_runtime_secs or setting it to 0 (unlimited)."
              )
          return self
  
label_desc: Use image node_id 2 for calling a global function with example usage: class_extensions() and returns: self, metalearner, model, model, self