code: def _test_master_restart_cmd(
      managed_cluster: Cluster, slots: int, downtime: int
  ) -> None:
      command = [
          "det",
          "-m",
          conf.make_master_url(),
          "command",
          "run",
          "-d",
          "--config",
          f"resources.slots={slots}",
          "echo weareready && sleep 30",
      ]
      command_id = subprocess.check_output(command).decode().strip()
  
      # Don't just check ready. We want to make sure the command's sleep has started.
      logs = ""
      for log in task_logs(
          api_utils.determined_test_session(), command_id, follow=True
      ):
          if "weareready" in log.log:
              break
          logs += log.log
      else:
          pytest.fail(
              f"did not get weareready in task logs, logs {logs}"
          )
  
      if downtime >= 0:
          managed_cluster.kill_master()
          time.sleep(downtime)
          managed_cluster.restart_master()
  
      wait_for_command_state(command_id, "TERMINATED", 30)
      assert_command_succeeded(command_id)
  
imports: import logging
  import subprocess
  import time
  import docker
  import pytest
  import requests
  from determined.common import constants
  from determined.common.api import authentication, task_is_ready, task_logs
  from determined.common.api.bindings import experimentv1State
  from tests import api_utils
  from tests import command
  from tests import config
  from tests import experiment
  from tests.cluster.test_users import det_spawn
  from .abstract_cluster import Cluster
  from .managed_cluster import ManagedCluster, get_agent_data
  from .managed_cluster_k8s import ManagedK8sCluster
  from .test_groups import det_cmd, det_cmd_json
  from .utils import assert_command_succeeded, run_command, wait_for_command_state, wait_for_task_state
label_desc: Use image node_id 14 for calling a global function with example usage: _test_master_restart_cmd(managed_cluster, slots, downtime) without return types