code: def test_metrics_monitor(capsys, test_settings):
      # test that the metrics monitor is able to robustly sample metrics
      mock_metric = MockMetric()
      mock_broken_metric = MockBrokenMetric()
      metrics = [mock_metric, mock_broken_metric]
      interface = AssetInterface()
      settings = SettingsStatic(
          test_settings(
              dict(
                  _stats_sample_rate_seconds=0.1,
                  _stats_samples_to_average=2,
              )
          ).to_proto()
      )
      shutdown_event = threading.Event()
  
      metrics_monitor = MetricsMonitor(
          asset_name="test_metrics_monitor",
          metrics=metrics,
          interface=interface,
          settings=settings,
          shutdown_event=shutdown_event,
      )
      metrics_monitor.start()
      time.sleep(1)
      shutdown_event.set()
      metrics_monitor.finish()
  
      while not interface.metrics_queue.empty():
          metric_record = interface.metrics_queue.get()
          assert metric_record == {mock_metric.name: 42}
  
      assert len(mock_metric.samples) == 0
  
imports: import threading
  import time
  from collections import deque
  from typing import TYPE_CHECKING, Any
  from unittest import mock
  import pytest
  import wandb
  from wandb.sdk.internal.settings_static import SettingsStatic
  from wandb.sdk.internal.system.assets import CPU, GPU, GPUAMD, IPU, TPU, Disk, GPUApple, Memory, Network, Trainium
  from wandb.sdk.internal.system.assets.asset_registry import asset_registry
  from wandb.sdk.internal.system.assets.interfaces import MetricsMonitor
  from wandb.sdk.internal.system.system_monitor import AssetInterface, SystemMonitor
label_desc: Use image node_id 2 for calling a global function with example usage: test_metrics_monitor(capsys, test_settings) without return types