code: def _setup_requeue(mocker):
      _setup(mocker)
      mocker.event = MagicMock()
      mocker.event.is_set = MagicMock(return_value=True)
  
      mocker.status = MagicMock()
      mocker.status.state = "preempted"
      mocker.run = MagicMock()
  
      _mock_get_status = AsyncMock(return_value=mocker.status)
      mocker.run.get_status = _mock_get_status
      mocker.runner = MagicMock()
  
      mocker.runner.run = AsyncMock(return_value=mocker.run)
  
      mocker.launch_add = MagicMock()
  
      mocker.project = MagicMock()
      mocker.patch(
          "wandb.sdk.launch.agent.agent.create_project_from_spec",
          mocker.project,
      )
      mocker.project.return_value.target_entity = "test-entity"
      mocker.project.return_value.run_id = "test-run-id"
  
      mocker.patch(
          "wandb.sdk.launch.agent.agent.fetch_and_validate_project",
          MagicMock(),
      )
      mocker.patch(
          "wandb.sdk.launch.agent.agent.loader.builder_from_config",
          return_value=None,
      )
      mocker.patch(
          "wandb.sdk.launch.agent.agent.loader.runner_from_config",
          return_value=mocker.runner,
      )
  
      mocker.api.fail_run_queue_item = MagicMock()
      mocker.patch(
          "wandb.sdk.launch.agent.agent.launch_add", mocker.launch_add
      )
  
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 3 for calling a global function with example usage: _setup_requeue(mocker) without return types