code: def test_log_policy_cancel_retries(should_match: bool) -> None:
      regex = r"assert 0 <= self\.metrics_sigma"
      if not should_match:
          regex = r"(.*) this should not match (.*)"
  
      config = conf.load_config(
          conf.fixtures_path("no_op/single-medium-train-step.yaml")
      )
      config["log_policies"] = [
          {
              "pattern": regex,
              "action": {
                  "type": "cancel_retries",
              },
          },
      ]
      config["hyperparameters"]["metrics_sigma"] = -1
      config["max_restarts"] = 1
  
      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.ERROR
      )
  
      experiment_trials = exp.experiment_trials(exp_id)
      assert len(experiment_trials) == 1
      trial_logs = "\n".join(
          exp.trial_logs(experiment_trials[0].trial.id)
      )
  
      if should_match:
          assert experiment_trials[0].trial.restarts == 0
          assert (
              "trial failed and matched logs to a don't retry policy"
              in trial_logs
          )
      else:
          assert experiment_trials[0].trial.restarts == 1
          assert (
              "trial failed and matched logs to a don't retry policy"
              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 1 for calling a global function with example usage: test_log_policy_cancel_retries(should_match) without return types