code: def test_apply_failed(tmp_dir, scm, dvc, failed_exp_stage, mocker):
      from dvc.repo.experiments.queue.base import (
          QueueDoneResult,
          QueueEntry,
      )
  
      dvc.experiments.run(
          failed_exp_stage.addressing,
          params=["foo=3"],
          queue=True,
          name="foo",
      )
      exp_rev = dvc.experiments.scm.resolve_rev(f"{CELERY_STASH}@{{0}}")
  
      # patch iter_done to return exp_rev as a failed exp (None-type result)
      queue = dvc.experiments.celery_queue
      mocker.patch.object(
          queue,
          "iter_done",
          return_value=[
              QueueDoneResult(
                  QueueEntry(
                      "", "", queue.ref, exp_rev, "", None, "foo", None
                  ),
                  None,
              ),
          ],
      )
      mocker.patch.object(
          queue,
          "iter_queued",
          return_value=[],
      )
  
      dvc.experiments.apply(exp_rev)
      assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 3"
  
      scm.reset(hard=True)
      assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 1"
      dvc.experiments.apply("foo")
      assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 3"
  
file_path: dvc/tests/func/experiments/test_apply.py
imports: import pytest
  from funcy import first
  from dvc.repo.experiments.refs import CELERY_STASH
label_desc: Use image node_id 2 for calling a global function with example usage: test_apply_failed(tmp_dir, scm, dvc, failed_exp_stage, mocker) without return types