code: def test_varimp():
      train = h2o.upload_file(
          pyunit_utils.locate(
              "smalldata/wine/winequality-redwhite-no-BOM.csv"
          )
      )
      y = "quality"
      # get at most one column from each type
      cols_to_test = []
      for col, typ in train.types.items():
          for ctt in cols_to_test:
              if typ == train.types[ctt] or col == y:
                  break
          else:
              cols_to_test.append(col)
  
      aml = H2OAutoML(seed=1234, max_models=5)
      aml.train(y=y, training_frame=train)
  
      assert aml.varimp(use_pandas=True).shape == (12, 5)
      assert h2o.explanation.varimp(
          aml.leaderboard[
              aml.leaderboard["model_id"].grep(
                  "Stacked", invert=True, output_logical=True
              ),
              :,
          ].head(3),
          num_of_features=3,
          use_pandas=True,
      ).shape == (3, 3)
  
      varimp_1 = aml.varimp(use_pandas=False)
      assert varimp_1[0].shape == (12, 5)
      assert len(varimp_1[1]) == 5
      assert len(varimp_1[2]) == 12
  
      varimp_2 = h2o.explanation.varimp(
          aml.leaderboard[
              aml.leaderboard["model_id"].grep(
                  "Stacked", invert=True, output_logical=True
              ),
              :,
          ].head(4),
          num_of_features=3,
          use_pandas=False,
      )
      assert varimp_2[0].shape == (3, 4)
      assert len(varimp_2[1]) == 4
      assert len(varimp_2[2]) == 3
  
      assert isinstance(
          aml.varimp_heatmap().figure(), matplotlib.pyplot.Figure
      )
      assert isinstance(
          h2o.varimp_heatmap(
              aml.leaderboard[
                  aml.leaderboard["model_id"].grep(
                      "Stacked", invert=True, output_logical=True
                  ),
                  :,
              ].head(3),
              num_of_features=3,
          ).figure(),
          matplotlib.pyplot.Figure,
      )
  
imports: import os
  import sys
  import pandas
  from h2o.grid import H2OGridSearch
  import matplotlib
  import h2o
  import pandas
  import matplotlib.pyplot
  from tests import pyunit_utils, test_plot_result_saving
  from h2o.automl import H2OAutoML
  from h2o.estimators import *
  from h2o.explanation._explain import H2OExplanation
label_desc: Use image node_id 2 for calling a global function with example usage: test_varimp() without return types