code: def _disable_agent(
      agent_id: str, drain: bool = False, json: bool = False
  ) -> Iterator[str]:
      command = (
          ["det", "-m", conf.make_master_url(), "agent", "disable"]
          + (["--drain"] if drain else [])
          + (["--json"] if json else [])
          + [agent_id]
      )
      try:
          with logged_in_user(conf.ADMIN_CREDENTIALS):
              out = subprocess.check_output(command).decode()
          yield out
      finally:
          with logged_in_user(conf.ADMIN_CREDENTIALS):
              command = [
                  "det",
                  "-m",
                  conf.make_master_url(),
                  "agent",
                  "enable",
                  agent_id,
              ]
              subprocess.check_call(command)
  
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 4 for calling a global function with example usage: _disable_agent(agent_id, drain, json) without return types