code: def _obtain_test_result(
      commits: Set[str], run_per_commit: int
  ) -> Dict[str, Dict[int, str]]:
      outcomes = {}
      wait = 5
      total_wait = 0
      while True:
          logger.info(
              f"... waiting for test result ...({total_wait} seconds)"
          )
          for commit in commits:
              if (
                  commit in outcomes
                  and len(outcomes[commit]) == run_per_commit
              ):
                  continue
              for run in range(run_per_commit):
                  outcome = (
                      subprocess.check_output(
                          [
                              "buildkite-agent",
                              "step",
                              "get",
                              "outcome",
                              "--step",
                              f"{commit}-{run}",
                          ]
                      )
                      .decode("utf-8")
                      .strip()
                  )
                  if not outcome:
                      continue
                  if commit not in outcomes:
                      outcomes[commit] = {}
                  outcomes[commit][run] = outcome
          all_commit_finished = len(outcomes) == len(commits)
          per_commit_finished = all(
              len(outcome) == run_per_commit
              for outcome in outcomes.values()
          )
          if all_commit_finished and per_commit_finished:
              break
          time.sleep(wait)
          total_wait = total_wait + wait
      logger.info(f"Final test outcomes: {outcomes}")
      return outcomes
  
imports: import click
  import copy
  import subprocess
  import os
  import json
  import time
  from typing import Dict, List, Set, Tuple
  from pathlib import Path
  from ray_release.bazel import bazel_runfile
  from ray_release.logger import logger
  from ray_release.buildkite.step import get_step
  from ray_release.byod.build import build_anyscale_base_byod_images, build_anyscale_custom_byod_image
  from ray_release.config import read_and_validate_release_test_collection
  from ray_release.configs.global_config import init_global_config
  from ray_release.test import Test
  from ray_release.test_automation.release_state_machine import ReleaseTestStateMachine
label_desc: Use image node_id 6 for calling a global function with example usage: _obtain_test_result(commits, run_per_commit) and returns: outcomes