code: def test_master_restart_error_missing_docker_container(
      managed_cluster_restarts: ManagedCluster,
      wait_for_amnesia: bool,
  ) -> None:
      exp_id = exp.create_experiment(
          conf.fixtures_path("core_api/sleep.yaml"),
          conf.fixtures_path("core_api"),
          None,
      )
  
      try:
          exp.wait_for_experiment_state(exp_id, EXP_STATE.RUNNING)
  
          client = docker.from_env()
          containers = client.containers.list()
  
          label = "ai.determined.container.description"
          containers = [
              c
              for c in containers
              if f"exp-{exp_id}" in c.labels.get(label, "")
          ]
          assert len(containers) == 1
  
          managed_cluster_restarts.kill_agent()
          managed_cluster_restarts.kill_master()
          containers[0].kill()
          managed_cluster_restarts.restart_master()
          managed_cluster_restarts.restart_agent(
              wait_for_amnesia=wait_for_amnesia
          )
  
          exp.wait_for_experiment_state(exp_id, EXP_STATE.RUNNING)
          trials = exp.experiment_trials(exp_id)
          trial_id = trials[0].trial.id
  
          expected_message = (
              (
                  "allocation failed due to agent failure: agent failed while the "
                  + "container was running: agent closed with allocated containers"
              )
              if wait_for_amnesia
              else (
                  "allocation failed due to restore error: RM failed "
                  + "to restore the allocation: container is gone on reattachment"
              )
          )
  
          for _ in range(30):
              trial_logs = "\n".join(exp.trial_logs(trial_id))
              if expected_message in trial_logs:
                  break
              time.sleep(1)
          assert expected_message in trial_logs
      finally:
          subprocess.check_call(
              [
                  "det",
                  "-m",
                  conf.make_master_url(),
                  "e",
                  "kill",
                  str(exp_id),
              ]
          )
          exp.wait_for_experiment_state(
              exp_id, EXP_STATE.CANCELED, max_wait_secs=20
          )
  
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 8 for calling a global function with example usage: test_master_restart_error_missing_docker_container(managed_cluster_restarts, wait_for_amnesia) without return types