code: def test_init_metrics():
      init_metrics()
      assert api._metric_backend == "console"
      shutdown_metrics()
      init_metrics("console")
      assert api._metric_backend == "console"
      shutdown_metrics()
      init_metrics(backend="console")
      assert api._metric_backend == "console"
      shutdown_metrics()
      init_metrics("prometheus")
      assert api._metric_backend == "prometheus"
      shutdown_metrics()
      init_metrics(backend="prometheus", config={"port": 0})
      assert api._metric_backend == "prometheus"
      shutdown_metrics()
      init_metrics("ray")
      assert api._metric_backend == "ray"
      shutdown_metrics()
      with pytest.raises(NotImplementedError):
          init_metrics("not_exist")
  
file_path: mars/mars/metrics/tests/test_metric_api.py
imports: import pytest
  from random import random
  from ..None import api
  from ..api import init_metrics, Metrics, _percentile_builder, Percentile, record_time_cost_percentile, shutdown_metrics
label_desc: Use image node_id 2 for calling a global function with example usage: test_init_metrics() without return types