code: def test_killed_pending_command_terminates() -> None:
      # Specify an outrageous number of slots to be sure that it can't be scheduled.
      # NB: slot # higher than postgres smallint (i.e. 32k) is rejected outright.
      with cmd.interactive_command(
          "cmd",
          "run",
          "--config",
          "resources.slots=10485",
          "sleep infinity",
      ) as command:
          assert command.task_id is not None
          for _ in range(10):
              assert (
                  cmd.get_command(command.task_id)["state"]
                  == "STATE_QUEUED"
              )
              time.sleep(1)
  
      # The command is killed when the context is exited; now it should reach TERMINATED soon.
      for _ in range(5):
          if (
              cmd.get_command(command.task_id)["state"]
              == "STATE_TERMINATED"
          ):
              break
          time.sleep(1)
      else:
          state = cmd.get_command(command.task_id)["state"]
          raise AssertionError(
              f"Task was in state {state} rather than STATE_TERMINATED"
          )
  
imports: import copy
  import re
  import subprocess
  import tempfile
  import time
  from pathlib import Path
  from typing import Any, Dict, List, Optional
  import docker
  import docker.errors
  import pytest
  from determined.common import util
  from tests import command
  from tests import config
  from tests.filetree import FileTree
label_desc: Use image node_id 19 for calling a global function with example usage: test_killed_pending_command_terminates() without return types