code: def test_validate_parallel_devices_indices(device_indices):
      """Test that the strategy validates that it doesn't support selecting specific devices by index.
  
      DeepSpeed doesn't support it and needs the index to match to the local rank of the process.
  
      """
      accelerator = Mock(spec=CUDAAccelerator)
      strategy = DeepSpeedStrategy(
          accelerator=accelerator,
          parallel_devices=[
              torch.device("cuda", i) for i in device_indices
          ],
      )
      with pytest.raises(
          RuntimeError,
          match=escape(
              f"device indices {device_indices!r} don't match the local rank values of processes"
          ),
      ):
          strategy.setup_environment()
      accelerator.setup_device.assert_called_once_with(
          torch.device("cuda", device_indices[0])
      )
  
imports: import json
  from re import escape
  from unittest import mock
  from unittest.mock import ANY, Mock
  import pytest
  import torch
  from lightning.fabric.accelerators import CPUAccelerator, CUDAAccelerator
  from lightning.fabric.strategies import DeepSpeedStrategy
  from torch.optim import Optimizer
  from tests_fabric.helpers.runif import RunIf
label_desc: Use image node_id 24 for calling a global function with example usage: test_validate_parallel_devices_indices(device_indices) without return types