code: def make_test_searcher(
      ops: List[int], dist: core.DistributedContext
  ) -> core.SearcherContext:
      # Mock the session.get to return a few searcher ops
      final_op = ops[-1]
      ops = list(ops)
  
      def session_get(_: Any) -> Any:
          assert (
              dist.rank == 0
          ), "worker SearcherContexts must not GET new ops, but ask the chief instead"
          resp = mock.MagicMock()
          if ops:
              resp.json.return_value = {
                  "op": {"validateAfter": {"length": str(ops.pop(0))}},
                  "completed": False,
              }
          else:
              resp.json.return_value = {
                  "op": {"validateAfter": {"length": str(final_op)}},
                  "completed": True,
              }
          return resp
  
      session = mock.MagicMock()
      session.get.side_effect = session_get
  
      searcher = core.SearcherContext(
          session=session,
          dist=dist,
          trial_id=1,
          run_id=2,
          allocation_id="3",
      )
      return searcher
  
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 1 for calling a global function with example usage: make_test_searcher(ops, dist) and returns: searcher, resp