code: def test_trials_interrupted_sigterm(storage, config, monkeypatch):
      """Check if a trial is set as interrupted when a signal is raised."""
  
      def mock_popen(self, *args, **kwargs):
          os.kill(os.getpid(), signal.SIGTERM)
  
      exp = experiment_builder.build(**config, storage=storage)
  
      monkeypatch.setattr(subprocess.Popen, "wait", mock_popen)
  
      trial = tuple_to_trial((1.0,), exp.space)
      exp.register_trial(trial)
      prepare_trial_working_dir(exp, trial)
  
      con = Consumer(exp)
  
      with pytest.raises(KeyboardInterrupt):
          with sigterm_as_interrupt():
              con(trial)
  
      shutil.rmtree(trial.working_dir)
  
imports: import logging
  import os
  import shutil
  import signal
  import subprocess
  import tempfile
  import pytest
  import orion.core.io.experiment_builder
  import orion.core.io.resolve_config
  import orion.core.utils.backward
  import orion.core.worker.consumer
  from orion.client.runner import prepare_trial_working_dir
  from orion.core.utils import sigterm_as_interrupt
  from orion.core.utils.exceptions import BranchingEvent, MissingResultFile
  from orion.core.utils.format_trials import tuple_to_trial
label_desc: Use image node_id 2 for calling a global function with example usage: test_trials_interrupted_sigterm(storage, config, monkeypatch) without return types