code: def test_gpu(monkeypatch):
      monkeypatch.setenv("RAY_scheduler_avoid_gpu_nodes", "1")
      n = 5
  
      cluster, cpu_node_ids, gpu_node_ids = build_cluster(n, n)
      try:
          ray.init(address=cluster.address)
  
          @ray.remote(num_cpus=1)
          class Actor1:
              def __init__(self):
                  pass
  
              def get_location(self):
                  return (
                      ray._private.worker.global_worker.node.unique_id
                  )
  
          @ray.remote(num_cpus=1)
          def task_cpu():
              time.sleep(10)
              return ray._private.worker.global_worker.node.unique_id
  
          @ray.remote(num_returns=2, num_gpus=0.5)
          def launcher():
              a = Actor1.remote()
              # Leave one cpu for the actor.
              task_results = [task_cpu.remote() for _ in range(n - 1)]
              actor_results = [
                  a.get_location.remote() for _ in range(n)
              ]
              return (
                  ray.get(task_results + actor_results),
                  ray._private.worker.global_worker.node.unique_id,
              )
  
          r = launcher.remote()
  
          ids, launcher_id = ray.get(r)
  
          assert (
              launcher_id in gpu_node_ids
          ), "expected launcher task to be scheduled on GPU nodes"
  
          for node_id in ids:
              assert (
                  node_id in cpu_node_ids
              ), "expected non-GPU tasks/actors to be scheduled on non-GPU nodes."
      finally:
          ray.shutdown()
          cluster.shutdown()
  
imports: import collections
  import logging
  import platform
  import subprocess
  import sys
  import time
  import unittest
  import numpy
  import pytest
  import ray
  import ray.cluster_utils
  import ray.util.accelerators
  from ray._private.internal_api import memory_summary
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy
  from ray._private.test_utils import Semaphore, SignalActor, object_memory_usage, get_metric_check_condition, wait_for_condition, MetricSamplePattern
label_desc: Use image node_id 16 for calling a global function with example usage: test_gpu(monkeypatch) and returns: ray, ray,  ray, ray