code: def test_accelerator_type_api(accelerator_type, shutdown_only):
      resource_name = f"{ray_constants.RESOURCE_CONSTRAINT_PREFIX}{accelerator_type}"
      ray.init(num_cpus=4, resources={resource_name: 1})
  
      quantity = 1
  
      @ray.remote(accelerator_type=accelerator_type)
      def decorated_func(quantity):
          wait_for_condition(
              lambda: ray.available_resources()[resource_name]
              < quantity
          )
          return True
  
      assert ray.get(decorated_func.remote(quantity))
  
      def via_options_func(quantity):
          wait_for_condition(
              lambda: ray.available_resources()[resource_name]
              < quantity
          )
          return True
  
      assert ray.get(
          ray.remote(via_options_func)
          .options(accelerator_type=accelerator_type)
          .remote(quantity)
      )
  
      @ray.remote(accelerator_type=accelerator_type)
      class DecoratedActor:
          def __init__(self):
              pass
  
          def initialized(self):
              pass
  
      class ActorWithOptions:
          def __init__(self):
              pass
  
          def initialized(self):
              pass
  
      decorated_actor = DecoratedActor.remote()
      # Avoid a race condition where the actor hasn't been initialized and
      # claimed the resources yet.
      ray.get(decorated_actor.initialized.remote())
      wait_for_condition(
          lambda: ray.available_resources()[resource_name] < quantity
      )
  
      quantity = ray.available_resources()[resource_name]
      with_options = (
          ray.remote(ActorWithOptions)
          .options(accelerator_type=accelerator_type)
          .remote()
      )
      ray.get(with_options.initialized.remote())
      wait_for_condition(
          lambda: ray.available_resources()[resource_name] < quantity
      )
  
imports: import glob
  import logging
  import multiprocessing
  import os
  import sys
  import tempfile
  import time
  from unittest import mock
  import numpy
  import psutil
  import pytest
  import ray
  import ray._private.gcs_utils
  import ray._private.ray_constants
  import ray._private.utils
  import ray.cluster_utils
  import ray.util.accelerators
  from ray._private.test_utils import wait_for_condition
  from ray.dashboard import k8s_utils
  from ray.runtime_env import RuntimeEnv
label_desc: Use image node_id 7 for calling a global function with example usage: test_accelerator_type_api(accelerator_type, shutdown_only) and returns: True, True