code: def test_gpu_and_neuron_cores(shutdown_only):
      num_gpus = 2
      num_nc = 2
      ray.init(
          num_cpus=2,
          num_gpus=num_gpus,
          resources={"neuron_cores": num_nc},
      )
  
      def get_gpu_ids(num_gpus_per_worker):
          gpu_ids = ray.get_gpu_ids()
          assert len(gpu_ids) == num_gpus_per_worker
          assert os.environ["CUDA_VISIBLE_DEVICES"] == ",".join(
              [str(i) for i in gpu_ids]  # noqa
          )
          for gpu_id in gpu_ids:
              assert gpu_id in range(num_gpus)
          gpu_ids_from_runtime_context = (
              ray.get_runtime_context().get_accelerator_ids()["GPU"]
          )
          for gpu_id in gpu_ids_from_runtime_context:
              assert gpu_id in [str(i) for i in range(num_gpus)]
          return len(gpu_ids)
  
      def get_neuron_core_ids(neuron_cores_per_worker):
          neuron_core_ids = (
              ray.get_runtime_context().get_accelerator_ids()[
                  "neuron_cores"
              ]
          )
          assert len(neuron_core_ids) == neuron_cores_per_worker
          cores = os.environ.get("NEURON_RT_VISIBLE_CORES")
          if cores is not None:
              assert cores == ",".join(
                  [str(i) for i in neuron_core_ids]
              )  # noqa
          for neuron_core_id in neuron_core_ids:
              assert neuron_core_id in [str(i) for i in range(num_nc)]
          return len(neuron_core_ids)
  
      gpu_f = ray.remote(num_gpus=2)(lambda: get_gpu_ids(2))
      assert ray.get(gpu_f.remote()) == 2
      nc_f = ray.remote(resources={"neuron_cores": 2})(
          lambda: get_neuron_core_ids(2)
      )
      assert ray.get(nc_f.remote()) == 2
  
imports: import logging
  import os
  import sys
  import time
  import numpy
  import pytest
  import ray
  import ray.cluster_utils
  from ray._private.test_utils import RayTestTimeoutException, wait_for_condition
  from ray.util.placement_group import placement_group
  from ray.util.accelerators import AWS_NEURON_CORE
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy
label_desc: Use image node_id 13 for calling a global function with example usage: test_gpu_and_neuron_cores(shutdown_only) and returns: len, len