code: def list_keys_in_memory(project_name=None):
      mem_keys = h2o.ls().key
      automl_keys = [
          k
          for k in mem_keys
          if re.search(r"_AutoML_", k)
          and (project_name is None or project_name not in k)
      ]
      automl_frame_keys = [
          k for k in mem_keys if re.search(r"^levelone_", k)
      ]
      prediction_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)
      ]
      metalearner_keys = [
          k for k in mem_keys if re.search(r"^metalearner", k)
      ]
      fold_keys = [k for k in mem_keys if re.search(r"_fold_", k)]
      all_model_keys = [
          k
          for k in automl_keys
          if k not in automl_frame_keys
          and k not in prediction_keys
          and k not in metrics_keys
          and k not in fold_keys
      ]
      cv_keys = [k for k in mem_keys if re.search(r"(^|_)cv_", k)]
      cv_prediction_keys = [k for k in cv_keys if k in prediction_keys]
      cv_metrics_keys = [k for k in cv_keys if k in metrics_keys]
      cv_fold_assignment = [k for k in cv_keys if k in fold_keys]
      cv_model_keys = [
          k
          for k in cv_keys
          if k in all_model_keys and k not in cv_fold_assignment
      ]
      base_model_keys = [
          k
          for k in all_model_keys
          if k not in cv_keys and k not in metalearner_keys
      ]
      return dict(
          all=mem_keys,
          models_all=all_model_keys,
          models_base=base_model_keys,
          predictions=prediction_keys,
          metrics=metrics_keys,
          automl=automl_keys,
          cv_all=cv_keys,
          cv_models=cv_model_keys,
          cv_predictions=cv_prediction_keys,
          cv_metrics=cv_metrics_keys,
          cv_fold_assignment=cv_fold_assignment,
          metalearners=metalearner_keys,
      )
  
file_path: h2o-3/h2o-py/tests/testdir_algos/automl/pyunit_automl_memory_cleanup.py
imports: import sys, os
  import re
  import h2o
  from h2o import H2OFrame
  from h2o.automl import H2OAutoML
  from tests import pyunit_utils
  from _automl_utils import import_dataset, get_partitioned_model_names
label_desc: Use image node_id 2 for calling a global function with example usage: list_keys_in_memory(project_name) and returns: dict