code: def _test_master_restart_shell(
      managed_cluster: Cluster, downtime: int
  ) -> None:
      with cmd.interactive_command(
          "shell", "start", "--detach"
      ) as shell:
          task_id = shell.task_id
  
          assert task_id is not None
          # Checking running is not correct here, running != ready for shells.
          task_is_ready(api_utils.determined_test_session(), task_id)
          pre_restart_queue = det_cmd_json(["job", "list", "--json"])
  
          if downtime >= 0:
              managed_cluster.kill_master()
              time.sleep(downtime)
              managed_cluster.restart_master()
  
          wait_for_task_state("shell", task_id, "RUNNING")
          post_restart_queue = det_cmd_json(["job", "list", "--json"])
          assert pre_restart_queue == post_restart_queue
  
          child = det_spawn(["shell", "open", task_id])
          child.setecho(True)
          child.expect(
              r".*Permanently added.+([0-9a-f-]{36}).+known hosts\."
          )
          child.sendline("det user whoami")
          child.expect(
              "You are logged in as user \\'(.*)\\'", timeout=10
          )
          child.sendline("exit")
          child.read()
          child.wait()
          assert child.exitstatus == 0
  
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 17 for calling a global function with example usage: _test_master_restart_shell(managed_cluster, downtime) without return types