code: def get_train_dataloader(train_ds: Any, cfg: Any, verbose=True):
      """Prepares train DataLoader.
  
      Args:
          train_ds: train Dataset
          cfg: input config
          verbose: whether to print the logs
  
      Returns:
          Train Dataloader
      """
  
      sampler: Sampler
      if cfg.environment._distributed:
          sampler = torch.utils.data.distributed.DistributedSampler(
              train_ds,
              num_replicas=cfg.environment._world_size,
              rank=cfg.environment._local_rank,
              shuffle=True,
              seed=cfg.environment._seed,
              drop_last=True,
          )
          sampler_length = len(sampler)
      else:
          sampler = None
          sampler_length = len(train_ds)
  
      if (
          sampler_length < cfg.training.batch_size
          and cfg.training.drop_last_batch
      ):
          logger.warning(
              "Training data too small when dropping last batch. Number of rows "
              "should be at least batch size multiplied by number of gpus. "
              "Forcing to keep last batch."
          )
          cfg.training.drop_last_batch = False
      if sampler_length <= 1:
          raise LLMDataException("Data too small to train model.")
  
      train_dataloader = DataLoader(
          train_ds,
          sampler=sampler,
          shuffle=(sampler is None),
          batch_size=cfg.training.batch_size,
          num_workers=cfg.environment.number_of_workers,
          pin_memory=True,
          collate_fn=train_ds.get_train_collate_fn(),
          drop_last=cfg.training.drop_last_batch,
          worker_init_fn=worker_init_fn,
      )
  
      if cfg.environment._local_rank == 0 and verbose:
          logger.info(
              f"Number of observations in train dataset: {len(train_ds)}"
          )
  
      return train_dataloader
  
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 12 for calling a global function with example usage: get_train_dataloader(train_ds, cfg, verbose) and returns: train_dataloader