code: def get_metrics(h2o_model, metric_type=None):
      """
      Extracts metrics from the H2O binary model.
  
      :param h2o_model: An H2O binary model.
      :param metric_type: The type of metrics. Possible values are "training", "validation", "cross_validation".
                          If parameter is not specified, metrics for all types are returned.
      :return: A dictionary of model metrics.
      """
  
      def get_metrics_section(output, prefix, metric_type):
          is_valid = lambda key, val: isinstance(
              val, (bool, float, int)
          ) and not str(key).endswith("checksum")
          items = output[metric_type]._metric_json.items()
          dictionary = dict(items)
          if dictionary["custom_metric_name"] is None:
              del dictionary["custom_metric_value"]
          return {
              prefix + str(key): val
              for key, val in dictionary.items()
              if is_valid(key, val)
          }
  
      metric_type_lower = None
      if metric_type:
          metric_type_lower = metric_type.toLowerCase()
  
      output = h2o_model._model_json["output"]
      metrics = {}
  
      if output["training_metrics"] and (
          metric_type_lower is None or metric_type_lower == "training"
      ):
          training_metrics = get_metrics_section(
              output, "training_", "training_metrics"
          )
          metrics = dict(metrics, **training_metrics)
      if output["validation_metrics"] and (
          metric_type_lower is None or metric_type_lower == "validation"
      ):
          validation_metrics = get_metrics_section(
              output, "validation_", "validation_metrics"
          )
          metrics = dict(metrics, **validation_metrics)
      if output["cross_validation_metrics"] and (
          metric_type_lower is None
          or metric_type_lower in ["cv", "cross_validation"]
      ):
          cross_validation_metrics = get_metrics_section(
              output, "cv_", "cross_validation_metrics"
          )
          metrics = dict(metrics, **cross_validation_metrics)
  
      return metrics
  
imports: import logging
  import os
  import tempfile
  import pandas
  import subprocess
  import sys
  import yaml
  import mlflow
  from mlflow import pyfunc
  from mlflow.models import Model
  from mlflow.models.model import MLMODEL_FILE_NAME
  from mlflow.models.utils import _save_example
  from mlflow.models import ModelSignature, ModelInputExample
  from mlflow.utils.environment import _CONDA_ENV_FILE_NAME, _CONSTRAINTS_FILE_NAME, _PYTHON_ENV_FILE_NAME, _REQUIREMENTS_FILE_NAME, _mlflow_conda_env, _process_conda_env, _process_pip_requirements, _PythonEnv, _validate_env_arguments
  from mlflow.utils.file_utils import write_to
  from mlflow.utils.model_utils import _get_flavor_configuration, _validate_and_copy_code_paths, _validate_and_prepare_target_save_path
  from mlflow.tracking.artifact_utils import _download_artifact_from_uri
  from mlflow.utils.requirements_utils import _get_pinned_requirement
label_desc: Use image node_id 4 for calling a global function with example usage: get_metrics(h2o_model, metric_type) and returns: metrics, unknown