code: def test_apply(tmp_dir, scm, dvc, exp_stage):
      from dvc.exceptions import InvalidArgumentError
  
      results = dvc.experiments.run(
          exp_stage.addressing, params=["foo=2"], tmp_dir=True
      )
      exp_a = first(results)
  
      dvc.experiments.run(
          exp_stage.addressing,
          params=["foo=3"],
          tmp_dir=True,
          name="foo",
      )
  
      with pytest.raises(InvalidArgumentError):
          dvc.experiments.apply("bar")
  
      dvc.experiments.apply(exp_a)
      assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 2"
      assert (tmp_dir / "metrics.yaml").read_text().strip() == "foo: 2"
  
      dvc.experiments.apply("foo")
      assert (tmp_dir / "params.yaml").read_text().strip() == "foo: 3"
      assert (tmp_dir / "metrics.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 1 for calling a global function with example usage: test_apply(tmp_dir, scm, dvc, exp_stage) without return types