code: def test_sweep_scheduler_start_failed(user, monkeypatch):
      _patch_wandb_run(monkeypatch)
      sweep_config = VALID_SWEEP_CONFIGS_MINIMAL[0]
      _entity = user
      _project = "test-project"
      api = internal.Api()
      # Entity, project, and sweep should be everything you need to create a scheduler
      sweep_id = wandb.sweep(
          sweep_config, entity=_entity, project=_project
      )
  
      api.stop_run = lambda run_id: True
      scheduler = SweepScheduler(
          api, sweep_id=sweep_id, entity=_entity, project=_project
      )
  
      # also test stop run
      assert scheduler._stop_run("nonexistent-run") is False
      scheduler._runs["existing-run-no-queued"] = SweepRun(
          id="existing-run-no-queued",
          state=RunState.RUNNING,
          worker_id=0,
      )
      assert scheduler._stop_run("existing-run-no-queued") is False
      scheduler._runs["existing-run-dead"] = SweepRun(
          id="existing-run-dead",
          state=RunState.CRASHED,
          worker_id=1,
          queued_run=Mock(spec=public.QueuedRun),
      )
      assert scheduler._stop_run("existing-run-dead") is True
      scheduler._runs["existing-run"] = SweepRun(
          id="existing-run",
          worker_id=2,
          queued_run=Mock(spec=public.QueuedRun),
      )
      assert scheduler._stop_run("existing-run")
  
      scheduler.state = SchedulerState.CANCELLED
      scheduler.start()
      # should not be able to start a cancelled scheduler
      assert scheduler.state == SchedulerState.CANCELLED
  
imports: import asyncio
  from typing import Dict
  from unittest.mock import Mock, patch
  import pytest
  import wandb
  from wandb.apis import internal, public
  from wandb.errors import CommError
  from wandb.sdk.launch.sweeps import SchedulerError, load_scheduler
  from wandb.sdk.launch.sweeps.scheduler import RunState, Scheduler, SchedulerState, SweepRun
  from wandb.sdk.launch.sweeps.scheduler_sweep import SweepScheduler
  from wandb.sdk.launch.sweeps.utils import construct_scheduler_args
  from .test_wandb_sweep import VALID_SWEEP_CONFIGS_MINIMAL
label_desc: Use image node_id 4 for calling a global function with example usage: test_sweep_scheduler_start_failed(user, monkeypatch) without return types