code: def test_disable_agent_experiment_resume() -> None:
      """
      Start an experiment with max_restarts=0 and ensure that being killed due to an explicit agent
      disable/enable (without draining) does not count toward the number of restarts.
      """
      slots = _fetch_slots()
      assert len(slots) == 1
      agent_id = slots[0]["agent_id"]
  
      exp_id = exp.create_experiment(
          conf.fixtures_path("no_op/single-medium-train-step.yaml"),
          conf.fixtures_path("no_op"),
          ["--config", "max_restarts=0"],
      )
      exp.wait_for_experiment_state(
          exp_id, experimentv1State.RUNNING, max_wait_secs=300
      )
  
      with _disable_agent(agent_id):
          # Wait for the allocation to go away.
          for _ in range(20):
              slots = _fetch_slots()
              print(slots)
              if not any(s["allocation_id"] != "FREE" for s in slots):
                  break
              time.sleep(1)
          else:
              pytest.fail(
                  "Experiment stayed scheduled after agent was disabled"
              )
      exp.wait_for_experiment_state(exp_id, experimentv1State.COMPLETED)
  
imports: import contextlib
  import json
  import subprocess
  import time
  from typing import Any, Dict, Iterator, List, Optional, cast
  import pytest
  from determined.common.api.bindings import experimentv1State, get_GetSlot
  from tests import api_utils
  from tests import config
  from tests import experiment
  from .test_users import logged_in_user
  from .utils import assert_command_succeeded, run_zero_slot_command, wait_for_command_state
label_desc: Use image node_id 5 for calling a global function with example usage: test_disable_agent_experiment_resume() without return types