class_docstr: Sampler that restricts data loading to a subset of the dataset.
  It is especially useful in conjunction with
  :class:`torch.nn.parallel.DistributedDataParallel`. In such case, each
  process can pass a DistributedSampler instance as a DataLoader sampler,
  and load a subset of the original dataset that is exclusive to it.
  Source:
  https://github.com/rwightman/pytorch-image-models/blob/master/timm/data/distributed_sampler.py
class_docstr_tok: ["Sampler","that","restricts","data","loading","to","a","subset","of","the","dataset",".","It","is","especially","useful","in","conjunction","with",":","class",":","`","torch.nn.parallel.DistributedDataParallel","`",".","In","such","case",",","each","process","can","pass","a","DistributedSampler","instance","as","a","DataLoader","sampler",",","and","load","a","subset","of","the","original","dataset","that","is","exclusive","to","it",".","Source",":","https",":","\/\/github.com\/rwightman\/pytorch-image-models\/blob\/master\/timm\/data\/distributed_sampler.py"]
docstr: Args:
      dataset: Dataset used for sampling
      num_replicas: Number of processes participating in distributed training
      rank: Rank of the current process within num_replicas
docstr_tok: ["Args",":","dataset",":","Dataset","used","for","sampling","num_replicas",":","Number","of","processes","participating","in","distributed","training","rank",":","Rank","of","the","current","process","within","num_replicas"]
code: def __init__(
      self,
      dataset: Any,
      num_replicas: Optional[int] = None,
      rank: Optional[int] = None,
  ):
      """
      Args:
          dataset: Dataset used for sampling
          num_replicas: Number of processes participating in distributed training
          rank: Rank of the current process within num_replicas
      """
  
      if num_replicas is None:
          if not dist.is_available():
              raise RuntimeError(
                  "Requires distributed package to be available"
              )
          num_replicas = dist.get_world_size()
      if rank is None:
          if not dist.is_available():
              raise RuntimeError(
                  "Requires distributed package to be available"
              )
          rank = dist.get_rank()
      self.dataset = dataset
      self.num_replicas = num_replicas
      self.rank = rank
      self.num_samples = int(
          math.ceil(len(self.dataset) * 1.0 / self.num_replicas)
      )
      self.total_size = self.num_samples * self.num_replicas
  
imports: import logging
  import math
  import os
  from typing import Any, DefaultDict, Dict, List, Optional, Tuple, Union, no_type_check
  import networkx
  import numpy
  import pandas
  import pyarrow.parquet
  import torch
  from sklearn.model_selection import GroupShuffleSplit, train_test_split
  from torch import distributed
  from torch.utils.data import DataLoader, Sampler, SequentialSampler
  from llm_studio.src.datasets.conversation_chain_handler import ConversationChainHandler
  from llm_studio.src.utils.exceptions import LLMDataException
  from llm_studio.src.utils.utils import PatchedAttribute, set_seed
label_desc: Use image node_id 1 to create a new OrderedDistributedSampler object from inherited base classes: Sampler with example: obj = OrderedDistributedSampler(dataset, num_replicas, rank)