code: def test_launch_agent_scheduler(
      monkeypatch, user, wandb_init, test_settings, max_schedulers
  ):
      proj = "123"
      queue = "queue"
      settings = test_settings({"project": proj})
      run = wandb_init(settings=settings)
  
      job_artifact = run._log_job_artifact_with_image(
          "docker_image", args=[]
      )
      job_name = job_artifact.wait().name
  
      api = wandb.sdk.internal.internal_api.Api()
      api.create_run_queue(
          entity=user, project=proj, queue_name=queue, access="USER"
      )
  
      sweep_config = {
          "job": job_name,
          "method": "bayes",
          "metric": {
              "name": "loss_metric",
              "goal": "minimize",
          },
          "parameters": {
              "epochs": {"value": 1},
              "increment": {"values": [0.1, 0.2, 0.3]},
          },
      }
  
      # Launch job spec for the Scheduler
      _launch_scheduler_spec = json.dumps(
          {
              "queue": queue,
              "run_spec": json.dumps(
                  construct_launch_spec(
                      Scheduler.PLACEHOLDER_URI,  # uri
                      None,  # job
                      api,
                      "Scheduler.WANDB_SWEEP_ID",  # name,
                      proj,
                      user,
                      None,  # docker_image,
                      "local-process",  # resource,
                      [
                          "wandb",
                          "scheduler",
                          "WANDB_SWEEP_ID",
                          "--queue",
                          queue,
                          "--project",
                          proj,
                          "--job",  # necessary?
                          job_name,
                      ],  # entry_point,
                      None,  # version,
                      None,  # resource_args,
                      None,  # launch_config,
                      None,  # run_id,
                      None,  # repository
                      user,  # author
                  )
              ),
          }
      )
  
      sweep_id, warnings = api.upsert_sweep(
          sweep_config,
          project=proj,
          entity=user,
          obj_id=None,
          launch_scheduler=_launch_scheduler_spec,
      )
  
      assert len(warnings) == 0
      assert sweep_id
  
      def _check_job(_, job):
          print(job)
          return
  
      def _raise(*args):
          raise KeyboardInterrupt
  
      monkeypatch.setattr(
          LaunchAgent,
          "run_job",
          _check_job,
      )
  
      api.ack_run_queue_item = _raise
  
      launch_agent = LaunchAgent(
          api=api,
          config={
              "entity": user,
              "project": proj,
              "queues": [queue],
              "max_schedulers": max_schedulers,
          },
      )
  
      if max_schedulers is None:
          assert launch_agent._max_schedulers == 1
      elif max_schedulers == -1:
          assert launch_agent._max_schedulers == float("inf")
      else:
          assert launch_agent._max_schedulers == int(max_schedulers)
      run.finish()
  
file_path: wandb/tests/pytest_tests/system_tests/test_launch/test_launch_sweep.py
imports: import json
  import pytest
  import wandb
  from wandb.apis.public import Api
  from wandb.sdk.launch.agent.agent import LaunchAgent
  from wandb.sdk.launch.sweeps.scheduler import Scheduler
  from wandb.sdk.launch.utils import construct_launch_spec
label_desc: Use image node_id 2 for calling a global function with example usage: test_launch_agent_scheduler(monkeypatch, user, wandb_init, test_settings, max_schedulers) without return types