code: def test_cuda_visible_devices_fractional(
      ray_2_node_2_gpu, worker_results
  ):
      config = TestConfig()
  
      if worker_results[0] != len(worker_results[1]):
          raise ValueError(
              "Invalid test parameter. Length of expected result should "
              "match number of workers."
          )
  
      def get_resources():
          cuda_visible_devices = os.environ["CUDA_VISIBLE_DEVICES"]
          # Sort the cuda visible devices to have exact match with expected result.
          sorted_devices = [
              int(device)
              for device in sorted(cuda_visible_devices.split(","))
          ]
          return sorted_devices
  
      num_workers, expected_results = worker_results
  
      os.environ[ENABLE_SHARE_CUDA_VISIBLE_DEVICES_ENV] = "1"
      e = BackendExecutor(
          config,
          num_workers=num_workers,
          num_cpus_per_worker=0,
          num_gpus_per_worker=0.5,
      )
      e.start()
      _start_training(e, get_resources)
      results = e.finish_training()
      results.sort()
      assert results == expected_results
  
imports: import math
  import os
  import tempfile
  import time
  from unittest.mock import patch
  import pytest
  import ray
  import ray._private.ray_constants
  from ray import train
  from ray.air._internal.util import StartTraceback
  from ray.tests.conftest import pytest_runtest_makereport
  from ray.train import DataConfig
  from ray.train._internal.backend_executor import BackendExecutor, InactiveWorkerGroupError, TrainBackendError, TrainingWorkerError
  from ray.train._internal.storage import StorageContext
  from ray.train._internal.worker_group import WorkerGroup, WorkerMetadata
  from ray.train.backend import Backend, BackendConfig
  from ray.train.constants import ENABLE_SHARE_CUDA_VISIBLE_DEVICES_ENV, ENABLE_SHARE_NEURON_CORES_ACCELERATOR_ENV, TRAIN_ENABLE_WORKER_SPREAD_ENV
  from ray.train.tensorflow import TensorflowConfig
  from ray.train.torch import TorchConfig
  from ray.util.placement_group import get_current_placement_group
  from ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy
label_desc: Use image node_id 18 for calling a global function with example usage: test_cuda_visible_devices_fractional(ray_2_node_2_gpu, worker_results) and returns: sorted_devices