code: def init_metrics(backend="console", config: Dict[str, Any] = None):
      global _init
      if _init is True:
          return
  
      backend = backend or "console"
      if backend not in _backends_cls:
          raise NotImplementedError(
              f"Do not support metric backend {backend}"
          )
      global _metric_backend
      _metric_backend = backend
      if _metric_backend == "prometheus":
          try:
              from prometheus_client import start_http_server
              from ..utils import get_next_port
  
              port = config.get("port", 0) if config else 0
              port = port or get_next_port()
              start_http_server(port)
              logger.warning(
                  "Finished startup prometheus http server and port is %d",
                  port,
              )
          except ImportError:
              logger.warning(
                  "Failed to start prometheus http server because there is no prometheus_client"
              )
      _init = True
      for m in _metrics_to_be_initialized:
          cls = getattr(_backends_cls[_metric_backend], m.type)
          metric = cls(m.name, m.description, m.tag_keys)
          m.set_metric(metric)
      logger.info(
          "Finished initialize the metrics of backend: %s.",
          _metric_backend,
      )
  
imports: import logging
  import time
  import weakref
  from contextlib import contextmanager
  from enum import Enum
  from queue import PriorityQueue
  from typing import Any, Callable, Dict, List, NamedTuple, Optional, Tuple
  from .backends.console import console_metric
  from .backends.metric import AbstractMetric
  from .backends.prometheus import prometheus_metric
  from .backends.ray import ray_metric
label_desc: Use image node_id 1 for calling a global function with example usage: init_metrics(backend, config) without return types