code: def test_max_concurrent_trials(name: str, searcher_cfg: str) -> None:
      config_obj = conf.load_config(
          conf.fixtures_path("no_op/single-very-many-long-steps.yaml")
      )
      config_obj["name"] = f"{name} searcher max concurrent trials test"
      config_obj["searcher"] = searcher_cfg
      config_obj["hyperparameters"]["x"] = {
          "type": "categorical",
          # Intentionally give the searcher more to do, in case a bug involves exceeding max
          # concurrent trials.
          "vals": list(range(16)),
      }
  
      with tempfile.NamedTemporaryFile() as tf:
          with open(tf.name, "w") as f:
              util.yaml_safe_dump(config_obj, f)
          experiment_id = exp.create_experiment(
              tf.name, conf.fixtures_path("no_op"), []
          )
  
      try:
          exp.wait_for_experiment_active_workload(experiment_id)
          trials = exp.wait_for_at_least_n_trials(experiment_id, 1)
          assert len(trials) == 1, trials
  
          for t in trials:
              exp.kill_trial(t.trial.id)
  
          # Give the experiment time to refill max_concurrent_trials.
          trials = exp.wait_for_at_least_n_trials(experiment_id, 2)
  
          # The experiment handling the cancel message and waiting for it to be cancelled slyly
          # (hackishly) allows us to synchronize with the experiment state after after canceling
          # the first two trials.
          exp.cancel_single(experiment_id)
  
          # Make sure that there were never more than 2 total trials created.
          trials = exp.wait_for_at_least_n_trials(experiment_id, 2)
          assert len(trials) == 2, trials
  
      finally:
          exp.kill_single(experiment_id)
  
imports: import json
  import subprocess
  import tempfile
  import pytest
  from determined.common import api, util
  from determined.common.api import bindings
  from determined.experimental import Determined
  from tests import api_utils
  from tests import command
  from tests import config
  from tests import experiment
  from tests.api_utils import determined_test_session
  from tests.cluster.test_checkpoints import wait_for_gc_to_finish
label_desc: Use image node_id 13 for calling a global function with example usage: test_max_concurrent_trials(name, searcher_cfg) without return types