code: def _get_distributed_sampler(
      dataloader: DataLoader,
      shuffle: bool,
      overfit_batches: Union[int, float],
      mode: Optional[RunningStage] = None,
      **kwargs: Any,
  ) -> DistributedSampler:
      """This function is used to created the distributed sampler injected within the user DataLoader."""
      kwargs["shuffle"] = shuffle and not overfit_batches
      kwargs.setdefault("seed", int(os.getenv("PL_GLOBAL_SEED", 0)))
      if mode == RunningStage.PREDICTING:
          return UnrepeatedDistributedSamplerWrapper(
              dataloader.sampler, **kwargs
          )
      if isinstance(
          dataloader.sampler, (RandomSampler, SequentialSampler)
      ):
          return DistributedSampler(dataloader.dataset, **kwargs)
      return DistributedSamplerWrapper(dataloader.sampler, **kwargs)
  
imports: import os
  from dataclasses import dataclass, field
  from typing import Any, Iterable, Optional, Tuple, Union
  import torch.multiprocessing
  from torch.utils.data import BatchSampler, DataLoader, RandomSampler, Sampler, SequentialSampler
  from torch.utils.data.distributed import DistributedSampler
  import lightning.pytorch
  from lightning.fabric.utilities.data import _auto_add_worker_init_fn, _replace_dunder_methods, _set_sampler_epoch, has_iterable_dataset, suggested_max_num_workers
  from lightning.fabric.utilities.distributed import DistributedSamplerWrapper
  from lightning.pytorch.overrides.distributed import UnrepeatedDistributedSamplerWrapper
  from lightning.pytorch.trainer import call
  from lightning.pytorch.trainer.states import RunningStage, TrainerFn
  from lightning.pytorch.utilities.combined_loader import CombinedLoader
  from lightning.pytorch.utilities.data import _is_dataloader_shuffled, _update_dataloader
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.imports import _graphcore_available_and_importable
  from lightning.pytorch.utilities.model_helpers import is_overridden
  from lightning.pytorch.utilities.rank_zero import WarningCache, rank_zero_warn
  from lightning.pytorch.utilities.types import EVAL_DATALOADERS, TRAIN_DATALOADERS
  from lightning.pytorch.utilities.warnings import PossibleUserWarning
label_desc: Use image node_id 1 for calling a global function with example usage: _get_distributed_sampler(dataloader, shuffle, overfit_batches, mode) and returns: DistributedSamplerWrapper, UnrepeatedDistributedSamplerWrapper, DistributedSampler