code: def test_shap_plots_with_background_frame():
      data = h2o.upload_file(
          pyunit_utils.locate(
              "smalldata/admissibleml_test/taiwan_credit_card_uci.csv"
          )
      )
  
      x = [
          "LIMIT_BAL",
          "AGE",
          "PAY_0",
          "PAY_2",
          "PAY_3",
          "PAY_4",
          "PAY_5",
          "PAY_6",
          "BILL_AMT1",
          "BILL_AMT2",
          "BILL_AMT3",
      ]
      # 'BILL_AMT4', 'BILL_AMT5', 'BILL_AMT6', 'PAY_AMT1', 'PAY_AMT2', 'PAY_AMT3', 'PAY_AMT4', 'PAY_AMT5', 'PAY_AMT6' ]
      y = "default payment next month"
      protected_columns = [
          "SEX",
          "EDUCATION",
      ]
      reference = ["1", "2"]
      favorable_class = "0"
      seed = 0xCAFFE
  
      for c in [y] + protected_columns:
          data[c] = data[c].asfactor()
  
      train, test = data[1:500, :].split_frame([0.98], seed=seed)
      print(test.nrow)
  
      aml = H2OAutoML(max_models=12, seed=seed)
      aml.train(x, y, train)
  
      models = []
      for algo in [
          "deeplearning",
          "drf",
          "gbm",
          "glm",
          "stackedensemble",
          "xgboost",
      ]:
          print(algo)
          model = aml.get_best_model(algo)
          models.append(model)
          # test shap summary
          assert isinstance(
              model.shap_summary_plot(
                  test, background_frame=train
              ).figure(),
              matplotlib.pyplot.Figure,
          )
          matplotlib.pyplot.close()
  
          # test shap explain row
          assert isinstance(
              model.shap_explain_row_plot(
                  test, 1, background_frame=train
              ).figure(),
              matplotlib.pyplot.Figure,
          )
          matplotlib.pyplot.close()
  
          # test fair shap plot
          for p in model.fair_shap_plot(
              test,
              "AGE",
              protected_columns,
              figsize=(4, 3),
              background_frame=train,
          ).values():
              assert isinstance(p, matplotlib.pyplot.Figure)
          matplotlib.pyplot.close()
  
          mf = model.inspect_model_fairness(
              test,
              protected_columns,
              reference,
              favorable_class,
              background_frame=train,
              render=False,
          )
          assert len(mf["shap"]["plots"]) > 1
          matplotlib.pyplot.close("all")
  
      # Test that explain has the correct shap plots
      print("checking explain")
      ex = h2o.explain(models, test, render=False)
      exb = h2o.explain(
          models, test, background_frame=train, render=False
      )
  
      ex_shap_plots = ex["shap_summary"]["plots"]
      exb_shap_plots = exb["shap_summary"]["plots"]
  
      assert len(ex_shap_plots) < len(exb_shap_plots)
  
      assert not any(
          "GLM" in k or "StackedEnsemble" in k or "DeepLearning" in k
          for k in ex_shap_plots.keys()
      )
      assert any(
          "GLM" in k or "StackedEnsemble" in k or "DeepLearning" in k
          for k in exb_shap_plots.keys()
      )
      ex, exb, ex_shap_plots, exb_shap_plots = None, None, None, None
      matplotlib.pyplot.close("all")
  
      print("checking explain_row")
      ex = h2o.explain_row(models, test, 1, render=False)
      exb = h2o.explain_row(
          models, test, 1, background_frame=train, render=False
      )
  
      ex_shap_plots = ex["shap_explain_row"]["plots"]
      exb_shap_plots = exb["shap_explain_row"]["plots"]
  
      assert len(ex_shap_plots) < len(exb_shap_plots)
  
      assert not any(
          "GLM" in k or "StackedEnsemble" in k or "DeepLearning" in k
          for k in ex_shap_plots.keys()
      )
      assert any(
          "GLM" in k or "StackedEnsemble" in k or "DeepLearning" in k
          for k in exb_shap_plots.keys()
      )
      ex, exb, ex_shap_plots, exb_shap_plots = None, None, None, None
      matplotlib.pyplot.close("all")
  
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 20 for calling a global function with example usage: test_shap_plots_with_background_frame() without return types