code: def test_celery_queue_kill(test_queue, mocker, force):
      mock_entry_foo = mocker.Mock(stash_rev="foo")
      mock_entry_bar = mocker.Mock(stash_rev="bar")
      mock_entry_foobar = mocker.Mock(stash_rev="foobar")
  
      mocker.patch.object(
          test_queue,
          "iter_active",
          return_value={
              mock_entry_foo,
              mock_entry_bar,
              mock_entry_foobar,
          },
      )
      mocker.patch.object(
          test_queue,
          "match_queue_entry_by_name",
          return_value={
              "bar": mock_entry_bar,
              "foo": mock_entry_foo,
              "foobar": mock_entry_foobar,
          },
      )
      mocker.patch.object(
          test_queue,
          "_get_running_task_ids",
          return_value={"foo", "foobar"},
      )
      mocker.patch.object(
          test_queue,
          "_iter_processed",
          return_value=[
              (mocker.Mock(headers={"id": "foo"}), mock_entry_foo),
              (mocker.Mock(headers={"id": "bar"}), mock_entry_bar),
              (
                  mocker.Mock(headers={"id": "foobar"}),
                  mock_entry_foobar,
              ),
          ],
      )
      mocker.patch.object(
          AsyncResult,
          "ready",
          return_value=False,
      )
      mark_mocker = mocker.patch.object(
          test_queue.celery.backend,
          "mark_as_failure",
      )
  
      def kill_function(rev):
          if rev == "foo":
              return True
          raise ProcessLookupError
  
      kill_mock = mocker.patch.object(
          test_queue.proc,
          "kill" if force else "interrupt",
          side_effect=mocker.MagicMock(side_effect=kill_function),
      )
      with pytest.raises(
          CannotKillTasksError, match="Task 'foobar' is initializing,"
      ):
          test_queue.kill(["bar", "foo", "foobar"], force=force)
      assert kill_mock.call_args_list == [
          mocker.call(mock_entry_bar.stash_rev),
          mocker.call(mock_entry_foo.stash_rev),
          mocker.call(mock_entry_foobar.stash_rev),
      ]
      mark_mocker.assert_called_once_with("bar", None)
  
file_path: dvc/tests/unit/repo/experiments/queue/test_celery.py
imports: import time
  import pytest
  from celery import shared_task
  from celery.result import AsyncResult
  from dvc.exceptions import DvcException
  from dvc.repo.experiments.exceptions import UnresolvedExpNamesError
  from dvc.repo.experiments.queue.base import QueueDoneResult
  from dvc.repo.experiments.queue.exceptions import CannotKillTasksError
label_desc: Use image node_id 6 for calling a global function with example usage: test_celery_queue_kill(test_queue, mocker, force) and returns: True