code: def _get_adb_path() -> str:
      """Define path to adb
  
      Order of search:
        1. From PATH
        2. From ANDROID_SDK_ROOT
        3. From ANDROID_HOME
        3. From default android sdk installation directory (platform specific)
      """
  
      def check_execution(exe_path):
          try:
              ret_code = subprocess.call(
                  [exe_path, "--version"],
                  stdout=subprocess.PIPE,
                  stderr=subprocess.PIPE,
              )
          except FileNotFoundError:
              ret_code = -1
  
          return ret_code == 0
  
      # Check if adb available via PATH
      if check_execution("adb"):
          return "adb"
  
      # Check if adb available via env vars or default directories
      list_of_paths = [
          os.environ.get("ANDROID_SDK_ROOT", default=""),
          os.environ.get("ANDROID_HOME", default=""),
      ]
  
      if sys.platform == "darwin":
          list_of_paths += [
              os.path.join(
                  pathlib.Path.home(),
                  "Library",
                  "Android",
                  "sdk",
                  "platform-tools",
              )
          ]
      if sys.platform == "win32":
          list_of_paths += [
              os.path.join(
                  pathlib.Path.home(),
                  "AppData",
                  "Local",
                  "Android",
                  "sdk",
                  "platform-tools",
              )
          ]
      if sys.platform == "linux":
          list_of_paths += [
              os.path.join(
                  pathlib.Path.home(),
                  "Android",
                  "Sdk",
                  "platform-tools",
              )
          ]
  
      list_of_paths = [path for path in list_of_paths if path != ""]
  
      found_path = None
      for candidate_path in list_of_paths:
          adb_path = os.path.join(candidate_path, "adb")
          if os.path.isfile(adb_path) and check_execution(adb_path):
              found_path = adb_path
              break
  
      if found_path is None:
          raise RuntimeError(
              "ADB was not found. It should be available via PATH, ANDROID_SDK_ROOT "
              "or ANDROID_HOME env var."
          )
  
      return found_path
  
imports: import abc
  import datetime
  import logging
  import multiprocessing
  import os
  import pathlib
  import signal
  import socket
  import stat
  import random
  import string
  import subprocess
  import sys
  import tempfile
  from typing import Union
  from tvm.contrib.hexagon.hexagon_profiler import HexagonProfiler
  from ..._ffi import libinfo
  from .session import Session
  from .tools import HEXAGON_SIMULATOR_NAME
label_desc: Use image node_id 4 for calling a global function with example usage: _get_adb_path() and returns: found_path, unknown, str