code: def find_vw_binary(
      test_base_ref_dir: Path,
      user_supplied_bin_path_or_python_invocation: Optional[str],
  ) -> Optional[Union[str, Path]]:
      def is_python_invocation(binary_name: Optional[str]) -> bool:
          if not binary_name:
              return False
          elif binary_name.startswith(
              "python"
          ) and binary_name.endswith("-m vowpalwabbit"):
              return True
          else:
              return False
  
      if is_python_invocation(
          user_supplied_bin_path_or_python_invocation
      ):
          return user_supplied_bin_path_or_python_invocation
  
      user_supplied_bin_path = (
          Path(user_supplied_bin_path_or_python_invocation)
          if user_supplied_bin_path_or_python_invocation is not None
          else None
      )
      vw_search_paths = [
          test_base_ref_dir / ".." / "build" / "vowpalwabbit" / "cli"
      ]
  
      def is_vw_binary(file: Path) -> bool:
          return file.name == "vw" or file.name == "vw.exe"
  
      return find_or_use_user_supplied_path(
          test_base_ref_dir=test_base_ref_dir,
          user_supplied_bin_path=user_supplied_bin_path,
          search_paths=vw_search_paths,
          is_correct_bin_func=is_vw_binary,
      )
  
imports: import shutil
  import threading
  import argparse
  import difflib
  from pathlib import Path
  import re
  import os
  import subprocess
  import sys
  import traceback
  import shlex
  import math
  import json
  from concurrent.futures import ThreadPoolExecutor, Future
  from enum import Enum
  import socket
  from typing import Any, Callable, Dict, List, Mapping, Optional, Set, Tuple, Type, Union, cast
  from run_tests_common import TestData
  import runtests_flatbuffer_converter
label_desc: Use image node_id 14 for calling a global function with example usage: find_vw_binary(test_base_ref_dir, user_supplied_bin_path_or_python_invocation) and returns: find_or_use_user_supplied_path, user_supplied_bin_path_or_python_invocation, unknown, False, True, False