code: def test_metric_exists(
      metrics: dict, expected_metrics_and_aliases: set
  ):
      """
      Ensure all expected metrics are present and no unexpected metrics are present
      """
      seen_metrics = set()
  
      for metric_name, metric_obj in metrics.items():
          assert (metric_name == metric_obj.name) or (
              metric_name in metric_obj.alias
          )
          assert metric_obj.greater_is_better is True
          if metric_name not in seen_metrics:
              seen_metrics.add(metric_name)
      diff_metrics = seen_metrics.symmetric_difference(
          expected_metrics_and_aliases
      )
      if len(diff_metrics) > 0:
          missing_metrics = expected_metrics_and_aliases.difference(
              seen_metrics
          )
          if len(missing_metrics) > 0:
              raise AssertionError(
                  f"Missing metrics: {list(missing_metrics)}"
              )
          else:
              unknown_metrics = seen_metrics.difference(
                  expected_metrics_and_aliases
              )
              raise AssertionError(
                  f"Invalid metrics (If you have added a new metric, "
                  f"please include it in the variable `expected_metrics_and_aliases`):"
                  f"\n\t{list(unknown_metrics)}"
              )
  
file_path: autogluon/core/tests/unittests/metrics/test_metrics.py
imports: from math import isclose
  import numpy
  import pytest
  import sklearn
  from autogluon.core.constants import BINARY, MULTICLASS, QUANTILE, REGRESSION
  from autogluon.core.metrics import METRICS, Scorer, rmse_func
label_desc: Use image node_id 1 for calling a global function with example usage: test_metric_exists(metrics, expected_metrics_and_aliases) without return types