code: def getFirstAvailable(
      order="first",
      maxLoad=0.5,
      maxMemory=0.5,
      attempts=1,
      interval=900,
      verbose=False,
      includeNan=False,
      excludeID=[],
      excludeUUID=[],
  ):
      # GPUs = getGPUs()
      # firstAvailableGPU = np.NaN
      # for i in range(len(GPUs)):
      #    if (GPUs[i].load < maxLoad) & (GPUs[i].memory < maxMemory):
      #        firstAvailableGPU = GPUs[i].id
      #        break
      # return firstAvailableGPU
      for i in range(attempts):
          if verbose:
              print(
                  "Attempting ("
                  + str(i + 1)
                  + "/"
                  + str(attempts)
                  + ") to locate available GPU."
              )
          # Get first available GPU
          available = getAvailable(
              order=order,
              limit=1,
              maxLoad=maxLoad,
              maxMemory=maxMemory,
              includeNan=includeNan,
              excludeID=excludeID,
              excludeUUID=excludeUUID,
          )
          # If an available GPU was found, break for loop.
          if available:
              if verbose:
                  print("GPU " + str(available) + " located!")
              break
          # If this is not the last attempt, sleep for 'interval' seconds
          if i != attempts - 1:
              time.sleep(interval)
      # Check if an GPU was found, or if the attempts simply ran out. Throw error, if no GPU was found
      if not (available):
          raise RuntimeError(
              "Could not find an available GPU after "
              + str(attempts)
              + " attempts with "
              + str(interval)
              + " seconds interval."
          )
  
      # Return found GPU
      return available
  
file_path: gputil/GPUtil/GPUtil.py
imports: from subprocess import Popen, PIPE
  from distutils import spawn
  import os
  import math
  import random
  import time
  import sys
  import platform
label_desc: Use image node_id 5 for calling a global function with example usage: getFirstAvailable(order, maxLoad, maxMemory, attempts, interval, verbose, includeNan, excludeID, excludeUUID) and returns: available