code: def _setup(mocker):
      mocker.api = MagicMock()
      mock_agent_response = {"name": "test-name", "stopPolling": False}
      mocker.api.get_launch_agent = MagicMock(
          return_value=mock_agent_response
      )
      mocker.api.fail_run_queue_item = MagicMock(
          side_effect=KeyboardInterrupt
      )
      mocker.termlog = MagicMock()
      mocker.termwarn = MagicMock()
      mocker.termerror = MagicMock()
      mocker.wandb_init = MagicMock()
      mocker.patch("wandb.termlog", mocker.termlog)
      mocker.patch("wandb.termwarn", mocker.termwarn)
      mocker.patch("wandb.termerror", mocker.termerror)
      mocker.patch("wandb.init", mocker.wandb_init)
  
      mocker.status = MagicMock()
      mocker.status.state = "running"
      mocker.run = MagicMock()
  
      # async def _mock_get_status(*args, **kwargs):
      #     return mocker.status
  
      mocker.run.get_status = AsyncMock(return_value=mocker.status)
      mocker.runner = MagicMock()
  
      async def _mock_runner_run(*args, **kwargs):
          return mocker.run
  
      mocker.runner.run = _mock_runner_run
      mocker.patch(
          "wandb.sdk.launch.agent.agent.loader.runner_from_config",
          return_value=mocker.runner,
      )
  
file_path: wandb/tests/pytest_tests/unit_tests/test_launch/test_agent/test_agent.py
imports: import asyncio
  import threading
  from unittest.mock import MagicMock
  import pytest
  from wandb.errors import CommError
  from wandb.sdk.launch.agent.agent import JobAndRunStatusTracker, LaunchAgent
  from wandb.sdk.launch.errors import LaunchDockerError, LaunchError
label_desc: Use image node_id 2 for calling a global function with example usage: _setup(mocker) and returns: mocker