code: def _setup_thread_finish(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()
      mocker.termlog = MagicMock()
      mocker.termerror = MagicMock()
      mocker.wandb_init = MagicMock()
      mocker.patch("wandb.termlog", mocker.termlog)
      mocker.patch("wandb.termerror", mocker.termerror)
      mocker.patch("wandb.init", mocker.wandb_init)
  
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 8 for calling a global function with example usage: _setup_thread_finish(mocker) without return types