code: def test_gpu(test_settings):
      mock_pynvml = MockPynvml()
  
      interface = AssetInterface()
      settings = SettingsStatic(
          test_settings(
              dict(
                  _stats_sample_rate_seconds=0.1,
                  _stats_samples_to_average=2,
              )
          ).to_proto()
      )
      shutdown_event = threading.Event()
  
      gpu = GPU(
          interface=interface,
          settings=settings,
          shutdown_event=shutdown_event,
      )
  
      with mock.patch.object(
          wandb.sdk.internal.system.assets.gpu,
          "pynvml",
          mock_pynvml,
      ), mock.patch.object(
          wandb.sdk.internal.system.assets.gpu,
          "gpu_in_use_by_this_process",
          lambda *_: True,
      ):
          assert gpu.is_available()
          gpu.start()
          assert gpu.probe() == {
              "gpu": "Mock GPU",
              "gpu_count": 1,
              "gpu_devices": [{"name": "Mock GPU", "memory_total": 42}],
          }
          time.sleep(1)
          shutdown_event.set()
          gpu.finish()
  
          assert not interface.metrics_queue.empty()
  
      assert gpu.probe() == {}
  
imports: import threading
  import time
  from typing import Tuple
  from unittest import mock
  import wandb
  from wandb.sdk.internal.settings_static import SettingsStatic
  from wandb.sdk.internal.system.assets import GPU
  from wandb.sdk.internal.system.system_monitor import AssetInterface
label_desc: Use image node_id 1 for calling a global function with example usage: test_gpu(test_settings) without return types