code: def _validate_device_index_selection(
      parallel_devices: List[torch.device],
  ) -> None:
      selected_device_indices = [
          device.index for device in parallel_devices
      ]
      expected_device_indices = list(range(len(parallel_devices)))
      if selected_device_indices != expected_device_indices:
          raise RuntimeError(
              f"The selected device indices {selected_device_indices!r} don't match the local rank values of processes."
              " If you need to select GPUs at a specific index, set the `CUDA_VISIBLE_DEVICES` environment variable"
              f" instead. For example: `CUDA_VISIBLE_DEVICES={','.join(str(i) for i in selected_device_indices)}`."
          )
  
imports: import argparse
  import json
  import logging
  import os
  import platform
  from contextlib import ExitStack
  from itertools import chain
  from pathlib import Path
  from typing import TYPE_CHECKING, Any, Callable, ContextManager, Dict, List, Mapping, Optional, Tuple, Union
  import torch
  from lightning_utilities.core.imports import RequirementCache
  from torch.nn import Module
  from torch.optim import Optimizer
  from typing_extensions import override
  from lightning.fabric.accelerators import Accelerator, CUDAAccelerator
  from lightning.fabric.plugins.environments.cluster_environment import ClusterEnvironment
  from lightning.fabric.plugins.precision import Precision
  from lightning.fabric.strategies.ddp import DDPStrategy
  from lightning.fabric.strategies.registry import _StrategyRegistry
  from lightning.fabric.strategies.strategy import _Sharded
  from lightning.fabric.utilities.distributed import log
  from lightning.fabric.utilities.load import _move_state_into
  from lightning.fabric.utilities.rank_zero import rank_zero_info, rank_zero_warn
  from lightning.fabric.utilities.seed import reset_seed
  from lightning.fabric.utilities.types import _PATH
label_desc: Use image node_id 3 for calling a global function with example usage: _validate_device_index_selection(parallel_devices) without return types