code: def _init():
      """Initialize the metrics mapping."""
      global _METRICS_MAPPING
  
      # Define the boundaries for bucketing times of distribution (Sampler) metrics.
  
      # Closure execution: range from 0.1s to 10000s, i.e. [(0.1, 1), (1, 10), ...]
      execution_time_buckets = monitoring.ExponentialBuckets(
          scale=0.1, growth_factor=10, bucket_count=6
      )
      # Tracing: same range as execution
      tracing_time_buckets = execution_time_buckets
      # Remote value fetch: range from 0.001s (i.e. 1ms) to 1000s
      fetch_time_buckets = monitoring.ExponentialBuckets(
          scale=0.001, growth_factor=10, bucket_count=7
      )
      # Server def update: range from 1s to 10000s
      server_update_time_buckets = monitoring.ExponentialBuckets(
          scale=1, growth_factor=10, bucket_count=5
      )
  
      function_tracing_sampler = monitoring.Sampler(
          "/tensorflow/api/ps_strategy/coordinator/function_tracing",
          tracing_time_buckets,
          "Sampler to track the time (in seconds) for tracing functions.",
      )
  
      closure_execution_sampler = monitoring.Sampler(
          "/tensorflow/api/ps_strategy/coordinator/closure_execution",
          execution_time_buckets,
          "Sampler to track the time (in seconds) for executing closures.",
      )
  
      remote_value_fetch_sampler = monitoring.Sampler(
          "/tensorflow/api/ps_strategy/coordinator/remote_value_fetch",
          fetch_time_buckets,
          "Sampler to track the time (in seconds) for fetching remote_value.",
      )
  
      server_def_update_sampler = monitoring.Sampler(
          "/tensorflow/api/ps_strategy/coordinator/server_def_update",
          server_update_time_buckets,
          "Sample to track the time (in seconds) for updating the server def upon "
          "worker recovery.",
      )
  
      queued_closure_gauge = monitoring.IntGauge(
          "/tensorflow/api/ps_strategy/coordinator/queued_closures",
          "Track how many closures are in the coordinator queue pending execution.",
      )
  
      inflight_closure_gauge = monitoring.IntGauge(
          "/tensorflow/api/ps_strategy/coordinator/inflight_closures",
          "Track how many closures are currently being processed by workers.",
      )
  
      worker_failure_counter = monitoring.Counter(
          "/tensorflow/api/ps_strategy/coordinator/recoverable_worker_failure_count",
          "Track how many recoverable worker failures have been encountered.",
      )
  
      _METRICS_MAPPING = {
          "function_tracing": function_tracing_sampler,
          "closure_execution": closure_execution_sampler,
          "remote_value_fetch": remote_value_fetch_sampler,
          "server_def_update": server_def_update_sampler,
          "queued_closures": queued_closure_gauge,
          "inflight_closures": inflight_closure_gauge,
          "worker_failures": worker_failure_counter,
      }
  
file_path: tensorflow-upstream/tensorflow/python/distribute/coordinator/metric_utils.py
imports: import time
  from tensorflow.python.eager import monitoring
  from tensorflow.python.util import tf_contextlib
label_desc: Use image node_id 1 for calling a global function with example usage: _init() without return types