code: def test_log_policy_exclude_node_k8s(should_match: bool) -> None:
      regex = r"assert 0 <= self\.metrics_sigma"
      if not should_match:
          regex = r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b"
  
      config = conf.load_config(
          conf.fixtures_path("no_op/single-medium-train-step.yaml")
      )
      config["log_policies"] = [
          {
              "pattern": regex,
              "action": {
                  "type": "exclude_node",
              },
          },
      ]
      config["hyperparameters"]["metrics_sigma"] = -1
      config["max_restarts"] = 1
  
      agents = bindings.get_GetAgents(
          api_utils.determined_test_session()
      ).agents
      assert len(agents) == 1
      assert agents[0].slots is not None
      config["resources"] = {"slots_per_trial": len(agents[0].slots)}
  
      with tempfile.NamedTemporaryFile() as tf:
          with open(tf.name, "w") as f:
              yaml.dump(config, f)
          exp_id = exp.create_experiment(
              tf.name, conf.fixtures_path("no_op")
          )
  
      exp.wait_for_experiment_state(
          exp_id, bindings.experimentv1State.RUNNING
      )
  
      if should_match:
          second_exp_id = exp.create_experiment(
              conf.fixtures_path("no_op/single-one-short-step.yaml"),
              conf.fixtures_path("no_op"),
          )
          exp.wait_for_experiment_state(
              second_exp_id, bindings.experimentv1State.COMPLETED
          )
  
          exp.wait_for_experiment_state(
              exp_id, bindings.experimentv1State.QUEUED
          )
  
          experiment_trials = exp.experiment_trials(exp_id)
          assert len(experiment_trials) == 1
          assert experiment_trials[0].trial.restarts == 1
          trial_logs = "\n".join(
              exp.trial_logs(experiment_trials[0].trial.id)
          )
          assert "therefore will not schedule on" in trial_logs
  
          exp.kill_experiments([exp_id])
      else:
          exp.wait_for_experiment_state(
              exp_id, bindings.experimentv1State.ERROR
          )
  
          experiment_trials = exp.experiment_trials(exp_id)
          assert len(experiment_trials) == 1
          assert experiment_trials[0].trial.restarts == 1
          trial_logs = "\n".join(
              exp.trial_logs(experiment_trials[0].trial.id)
          )
          assert "therefore will not schedule on" not in trial_logs
  
file_path: determined/e2e_tests/tests/cluster/test_log_policies.py
imports: import tempfile
  import pytest
  import yaml
  from determined.common.api import bindings
  from tests import api_utils
  from tests import config
  from tests import experiment
label_desc: Use image node_id 2 for calling a global function with example usage: test_log_policy_exclude_node_k8s(should_match) without return types