code: def allocate_gpus(gpus_needed, resources_needed={}, config=None):
      # Only disable gpus if gpus_needed < 0
      if gpus_needed < 0:
          os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
          return True
      elif gpus_needed == 0:
          return True
  
      gpu_mem_needed = resources_needed.get("gpuMem", None)
      strict = resources_needed.get("gpuMemStrict", False)
  
      available_gpus = get_available_gpus(gpu_mem_needed, strict)
      gpu_mapping = get_gpu_mapping()
      mapped_gpus = [str(gpu_mapping[g]) for g in available_gpus]
  
      os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
      if len(mapped_gpus) >= gpus_needed:
          os.environ["CUDA_VISIBLE_DEVICES"] = ",".join(
              mapped_gpus[:gpus_needed]
          )
          return True
      else:
          return False
  
imports: import os
  import sys
  import subprocess
  import argparse
  import json
  import psutil
  import time
  import six
  import signal
  import pdb
  from apscheduler.schedulers.background import BackgroundScheduler
  from studio import fs_tracker, model
  from studio.util import logs
  from studio.queues.local_queue import LocalQueue
  from studio.util.gpu_util import get_available_gpus, get_gpu_mapping, get_gpus_summary
  from studio.artifacts.artifact import Artifact
  from studio.experiments.experiment import Experiment
  from studio.util.util import sixdecode, str2duration, retry, parse_verbosity, check_for_kb_interrupt
label_desc: Use image node_id 2 for calling a global function with example usage: allocate_gpus(gpus_needed, resources_needed, config) and returns: True, True, False, True