code: def list_keys_in_memory():
      mem_keys = h2o.ls().key
      gbm_keys = [
          k
          for k in mem_keys
          if re.search(r"^Grid_GBM_.*_model_\d+(_|$)", k)
      ]
      pred_keys = [
          k for k in mem_keys if re.search(r"(^|_)prediction_", k)
      ]
      metrics_keys = [
          k for k in mem_keys if re.search(r"^modelmetrics_", k)
      ]
      model_keys = [
          k
          for k in gbm_keys
          if k not in pred_keys and k not in metrics_keys
      ]
      cv_keys = [k for k in mem_keys if re.search(r"(^|_)cv_", k)]
      cv_pred_keys = [k for k in cv_keys if k in pred_keys]
      cv_metrics_keys = [k for k in cv_keys if k in metrics_keys]
      cv_mod_keys = [k for k in cv_keys if k in model_keys]
      return dict(
          all=mem_keys,
          models=model_keys,
          predictions=pred_keys,
          metrics=metrics_keys,
          gbm=gbm_keys,
          cv_all=cv_keys,
          cv_models=cv_mod_keys,
          cv_predictions=cv_pred_keys,
          cv_metrics=cv_metrics_keys,
      )
  
file_path: h2o-3/h2o-py/tests/testdir_algos/gbm/pyunit_gbm_grid_memory_cleanup.py
imports: import sys
  from collections import OrderedDict
  import re
  import h2o
  from tests import pyunit_utils
  from h2o.grid.grid_search import H2OGridSearch
  from h2o.estimators.gbm import H2OGradientBoostingEstimator
label_desc: Use image node_id 1 for calling a global function with example usage: list_keys_in_memory() and returns: dict