docstr: The AcceleratorConnector parses several Trainer arguments and instantiates the Strategy including other
  components such as the Accelerator and Precision plugins.
  
      A. accelerator flag could be:
          1. accelerator class
          2. accelerator str
          3. accelerator auto
  
      B. strategy flag could be:
          1. strategy class
          2. strategy str registered with StrategyRegistry
  
      C. plugins flag could be:
          1. precision class (should be removed, and precision flag should allow user pass classes)
          2. checkpoint_io class
          3. cluster_environment class
  
  priorities which to take when:
      A. Class > str
      B. Strategy > Accelerator/precision/plugins
code: def __init__(
      self,
      devices: Union[List[int], str, int] = "auto",
      num_nodes: int = 1,
      accelerator: Union[str, Accelerator] = "auto",
      strategy: Union[str, Strategy] = "auto",
      plugins: Optional[
          Union[_PLUGIN_INPUT, List[_PLUGIN_INPUT]]
      ] = None,
      precision: Optional[_PRECISION_INPUT] = None,
      sync_batchnorm: bool = False,
      benchmark: Optional[bool] = None,
      use_distributed_sampler: bool = True,
      deterministic: Optional[Union[bool, _LITERAL_WARN]] = None,
  ) -> None:
      """The AcceleratorConnector parses several Trainer arguments and instantiates the Strategy including other
      components such as the Accelerator and Precision plugins.
  
          A. accelerator flag could be:
              1. accelerator class
              2. accelerator str
              3. accelerator auto
  
          B. strategy flag could be:
              1. strategy class
              2. strategy str registered with StrategyRegistry
  
          C. plugins flag could be:
              1. precision class (should be removed, and precision flag should allow user pass classes)
              2. checkpoint_io class
              3. cluster_environment class
  
      priorities which to take when:
          A. Class > str
          B. Strategy > Accelerator/precision/plugins
  
      """
      self.use_distributed_sampler = use_distributed_sampler
      _set_torch_flags(deterministic=deterministic, benchmark=benchmark)
  
      # 1. Parsing flags
      # Get registered strategies, built-in accelerators and precision plugins
      _register_external_accelerators_and_strategies()
      self._registered_strategies = (
          StrategyRegistry.available_strategies()
      )
      self._accelerator_types = (
          AcceleratorRegistry.available_accelerators()
      )
  
      # Raise an exception if there are conflicts between flags
      # Set each valid flag to `self._x_flag` after validation
      self._strategy_flag: Union[Strategy, str] = "auto"
      self._accelerator_flag: Union[Accelerator, str] = "auto"
      self._precision_flag: _PRECISION_INPUT_STR = "32-true"
      self._precision_plugin_flag: Optional[Precision] = None
      self._cluster_environment_flag: Optional[
          Union[ClusterEnvironment, str]
      ] = None
      self._parallel_devices: List[Union[int, torch.device, str]] = []
      self._layer_sync: Optional[LayerSync] = (
          TorchSyncBatchNorm() if sync_batchnorm else None
      )
      self.checkpoint_io: Optional[CheckpointIO] = None
  
      self._check_config_and_set_final_flags(
          strategy=strategy,
          accelerator=accelerator,
          precision=precision,
          plugins=plugins,
          sync_batchnorm=sync_batchnorm,
      )
  
      # 2. Instantiate Accelerator
      # handle `auto`, `None` and `gpu`
      if self._accelerator_flag == "auto":
          self._accelerator_flag = self._choose_auto_accelerator()
      elif self._accelerator_flag == "gpu":
          self._accelerator_flag = (
              self._choose_gpu_accelerator_backend()
          )
  
      self._check_device_config_and_set_final_flags(
          devices=devices, num_nodes=num_nodes
      )
      self._set_parallel_devices_and_init_accelerator()
  
      # 3. Instantiate ClusterEnvironment
      self.cluster_environment: ClusterEnvironment = (
          self._choose_and_init_cluster_environment()
      )
  
      # 4. Instantiate Strategy - Part 1
      if self._strategy_flag == "auto":
          self._strategy_flag = self._choose_strategy()
      # In specific cases, ignore user selection and fall back to a different strategy
      self._check_strategy_and_fallback()
      self._init_strategy()
  
      # 5. Instantiate Precision Plugin
      self.precision_plugin = self._check_and_init_precision()
  
      # 6. Instantiate Strategy - Part 2
      self._lazy_init_strategy()
  
imports: import logging
  import os
  from collections import Counter
  from typing import Dict, List, Literal, Optional, Union
  import torch
  from lightning.fabric.connector import _PRECISION_INPUT, _PRECISION_INPUT_STR, _convert_precision_to_unified_args
  from lightning.fabric.plugins.environments import ClusterEnvironment, LightningEnvironment, LSFEnvironment, MPIEnvironment, SLURMEnvironment, TorchElasticEnvironment
  from lightning.fabric.utilities.device_parser import _determine_root_gpu_device
  from lightning.fabric.utilities.imports import _IS_INTERACTIVE
  from lightning.pytorch.accelerators import AcceleratorRegistry
  from lightning.pytorch.accelerators.accelerator import Accelerator
  from lightning.pytorch.accelerators.cuda import CUDAAccelerator
  from lightning.pytorch.accelerators.mps import MPSAccelerator
  from lightning.pytorch.accelerators.xla import XLAAccelerator
  from lightning.pytorch.plugins import _PLUGIN_INPUT, CheckpointIO, DeepSpeedPrecision, DoublePrecision, FSDPPrecision, HalfPrecision, MixedPrecision, Precision, TransformerEnginePrecision, XLAPrecision
  from lightning.pytorch.plugins.layer_sync import LayerSync, TorchSyncBatchNorm
  from lightning.pytorch.strategies import DDPStrategy, DeepSpeedStrategy, FSDPStrategy, ParallelStrategy, SingleDeviceStrategy, SingleDeviceXLAStrategy, Strategy, StrategyRegistry, XLAStrategy
  from lightning.pytorch.strategies.ddp import _DDP_FORK_ALIASES
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.imports import _LIGHTNING_BAGUA_AVAILABLE, _LIGHTNING_COLOSSALAI_AVAILABLE, _graphcore_available_and_importable, _habana_available_and_importable
  from lightning.pytorch.utilities.rank_zero import rank_zero_info, rank_zero_warn
label_desc: Use image node_id 1 to create a new _AcceleratorConnector object  with example: obj = _AcceleratorConnector(devices, num_nodes, accelerator, strategy, plugins, precision, sync_batchnorm, benchmark, use_distributed_sampler, deterministic)