code: def test_launch_agent_runs(
      test_settings,
      live_mock_server,
      mocked_fetchable_git_repo,
      monkeypatch,
  ):
      monkeypatch.setattr(
          wandb.sdk.launch.agent.LaunchAgent,
          "pop_from_queue",
          lambda c, queue: patched_pop_from_queue(c, queue),
      )
  
      def mock_raise_exception():
          raise Exception
  
      monkeypatch.setattr(
          multiprocessing.pool.Pool,
          "apply_async",
          lambda x, y: mock_raise_exception(),
      )
      api = wandb.sdk.internal.internal_api.Api(
          default_settings=test_settings, load_settings=False
      )
      api.entity_is_team = MagicMock(return_value=False)
      config = {
          "entity": "mock_server_entity",
          "project": "test",
      }
      _launch.create_and_run_agent(api, config)
      ctx = live_mock_server.get_ctx()
      assert ctx["num_popped"] == 1
      assert len(ctx["launch_agents"].keys()) == 1
  
imports: import json
  import multiprocessing.pool
  import os
  import sys
  from unittest import mock
  from unittest.mock import MagicMock
  import pytest
  import wandb
  import wandb.sdk.launch._launch
  import wandb.sdk.launch._project_spec
  import yaml
  from wandb.apis import PublicApi
  from wandb.sdk.launch.agent.agent import LaunchAgent
  from wandb.sdk.launch.builder.build import _inject_wandb_config_env_vars
  from wandb.sdk.launch.builder.docker_builder import DockerBuilder
  from wandb.sdk.launch.errors import LaunchError
  from wandb.sdk.launch.utils import LAUNCH_DEFAULT_PROJECT, PROJECT_SYNCHRONOUS, pull_docker_image
  from wandb.sdk.lib import runid
  from tests.pytest_tests.unit_tests_old.utils import fixture_open, notebook_path
label_desc: Use image node_id 21 for calling a global function with example usage: test_launch_agent_runs(test_settings, live_mock_server, mocked_fetchable_git_repo, monkeypatch) without return types