code: def test_selection__too_many_errors(mocker: MockerFixture) -> None:
      dataset_id = utils.generate_id()
      job_id = "some-job-id"
      mocker.patch("time.sleep")
      mocked_print = mocker.patch("builtins.print")
      mocker.patch.object(
          ApiWorkflowClient, "__init__", return_value=None
      )
      mocker.patch.object(
          ApiWorkflowClient,
          "get_all_tags",
          return_value=_get_tags(dataset_id=dataset_id),
      )
  
      mocker.patch.object(
          ApiWorkflowClient,
          "_create_selection_create_request",
          return_value=_get_sampling_create_request(),
      )
  
      mocked_selection_api = mocker.MagicMock()
      mocked_sampling_response = mocker.MagicMock()
      mocked_sampling_response.job_id = job_id
      mocked_selection_api.trigger_sampling_by_id.return_value = (
          mocked_sampling_response
      )
  
      mocked_jobs_api = mocker.MagicMock()
      mocked_get_job_status = mocker.MagicMock(
          side_effect=[Exception("surprise!") for _ in range(20)]
      )
      mocked_jobs_api.get_job_status_by_id = mocked_get_job_status
  
      client = ApiWorkflowClient()
      client._selection_api = mocked_selection_api
      client._jobs_api = mocked_jobs_api
      client._dataset_id = dataset_id
      client.embedding_id = "embedding-id"
      with pytest.raises(Exception) as exception:
          client.selection(
              selection_config=SelectionConfig(name="some-tag")
          )
          assert str(exception.value) == "surprise!"
          mocked_print.assert_called_once_with(
              "Selection job with job_id some-job-id could not be started "
              "because of error: surprise!"
          )
  
file_path: lightly/tests/api_workflow/test_api_workflow_selection.py
imports: from typing import List
  import pytest
  from pytest_mock import MockerFixture
  from lightly.active_learning.config.selection_config import SelectionConfig
  from lightly.api import ApiWorkflowClient, api_workflow_selection
  from lightly.openapi_generated.swagger_client.models import JobResultType, JobState, JobStatusData, JobStatusDataResult, SamplingCreateRequest, SamplingMethod, TagData
  from tests.api_workflow import utils
label_desc: Use image node_id 7 for calling a global function with example usage: test_selection__too_many_errors(mocker) without return types