code: def test_searcher_workers_ask_chief(dummy: bool) -> None:
      with parallel.Execution(2) as pex:
  
          @pex.run
          def searchers() -> core.SearcherContext:
              if not dummy:
                  searcher = make_test_searcher(
                      [5, 10, 15], pex.distributed
                  )
              else:
                  searcher = core.DummySearcherContext(
                      dist=pex.distributed
                  )
              epochs_trained = 0
              # Iterate through ops.
              for op in searcher.operations():
                  assert (
                      pex.distributed.allgather(op.length)
                      == [op.length] * pex.size
                  )
                  while epochs_trained < op.length:
                      epochs_trained += 1
                      expect = [epochs_trained] * pex.size
                      assert (
                          pex.distributed.allgather(epochs_trained)
                          == expect
                      )
                      with parallel.raises_when(
                          pex.rank != 0,
                          RuntimeError,
                          match="op.report_progress.*chief",
                      ):
                          op.report_progress(epochs_trained)
                  with parallel.raises_when(
                      pex.rank != 0,
                      RuntimeError,
                      match="op.report_completed.*chief",
                  ):
                      op.report_completed(0.0)
  
              return searcher
  
          if not dummy:
              # Expect calls from chief: 15x progress, 4x completions
              chief = searchers[0]
              post_mock: Any = chief._session.post
              assert (
                  post_mock.call_count == 19
              ), post_mock.call_args_list
  
              # The workers must not make any REST API calls at all.
              worker = searchers[1]
              post_mock = worker._session.post
              post_mock.assert_not_called()
  
file_path: determined/harness/tests/core/test_searcher.py
imports: from typing import Any, List
  from unittest import mock
  import pytest
  from determined import core
  from tests import parallel
label_desc: Use image node_id 2 for calling a global function with example usage: test_searcher_workers_ask_chief(dummy) and returns: searcher