code: def get_glrm_xmatrix(
      train, test, K=3, compare_predict=True, tol=1e-1
  ):
      x = train.names
      transform_types = [
          "NONE",
          "STANDARDIZE",
          "NORMALIZE",
          "DEMEAN",
          "DESCALE",
      ]
      transformN = transform_types[randint(0, len(transform_types) - 1)]
      print("dataset transform is {0}.".format(transformN))
      # build a GLRM model with random dataset generated earlier
      glrmModel = H2OGeneralizedLowRankEstimator(
          k=K, transform=transformN, max_iterations=1000, seed=12345
      )
      glrmModel.train(x=x, training_frame=train)
      glrmTrainFactor = h2o.get_frame(
          glrmModel._model_json["output"]["representation_name"]
      )
  
      # assert glrmTrainFactor.nrows==train.nrows, \
      #     "X factor row number {0} should equal training row number {1}.".format(glrmTrainFactor.nrows, train.nrows)
      mojoDir = save_GLRM_mojo(glrmModel)  # save mojo model
  
      MOJONAME = pyunit_utils.getMojoName(glrmModel._id)
      h2o.download_csv(
          test[x], os.path.join(mojoDir, "in.csv")
      )  # save test file, h2o predict/mojo use same file
  
      frameID, mojoXFactor = pyunit_utils.mojo_predict(
          glrmModel, mojoDir, MOJONAME, glrmReconstruct=False
      )  # save mojo XFactor
      print("Comparing mojo x Factor and model x Factor ...")
  
      if transformN == "NONE" or not (
          compare_predict
      ):  # bad performance with no transformation on dataset
          pyunit_utils.check_data_rows(
              mojoXFactor, glrmTrainFactor, num_rows=mojoXFactor.nrow
          )
      else:
          pyunit_utils.compare_data_rows(
              mojoXFactor,
              glrmTrainFactor,
              index_list=range(2, mojoXFactor.nrows - 1),
              tol=tol,
          )
  
      if (
          compare_predict
      ):  # only compare reconstructed data frames with numerical data
          pred2 = glrmModel.predict(test)  # predict using mojo
          pred1 = glrmModel.predict(
              train
          )  # predict using the X from A=X*Y from training
  
          predictDiff = pyunit_utils.compute_frame_diff(train, pred1)
          mojoDiff = pyunit_utils.compute_frame_diff(train, pred2)
          print(
              "absolute difference of mojo predict and original frame is {0} and model predict and original frame is {1}".format(
                  mojoDiff, predictDiff
              )
          )
  
file_path: h2o-3/h2o-py/tests/testdir_javapredict/pyunit_pubdev_5826_glrm_predict_large.py
imports: import sys, os
  import h2o
  from tests import pyunit_utils
  from h2o.estimators.glrm import H2OGeneralizedLowRankEstimator
  from random import randint
  import re
label_desc: Use image node_id 2 for calling a global function with example usage: get_glrm_xmatrix(train, test, K, compare_predict, tol) without return types