code: def get_data_loader_sequential(
      data_loader: DataLoader, shuffle: bool = False, n_samples=None
  ) -> DataLoader:
      """Create new DataLoader with sampler of type IndicesSequentialSampler. This makes the data loader have \
      consistent batches order."""
      # First set generator seed to make it reproducible
      if data_loader.generator:
          data_loader.generator.set_state(
              torch.Generator().manual_seed(42).get_state()
          )
      indices = []
      batch_sampler = data_loader.batch_sampler
      # Using the batch sampler to get all indices
      for batch in batch_sampler:
          indices += batch
      if shuffle:
          indices = random.sample(indices, len(indices))
      if n_samples is not None:
          indices = indices[:n_samples]
  
      # Create new sampler and batch sampler
      sampler = IndicesSequentialSampler(indices)
      new_batch_sampler = BatchSampler(
          sampler, batch_sampler.batch_size, batch_sampler.drop_last
      )
  
      props = _get_data_loader_props(data_loader)
      props["batch_sampler"] = new_batch_sampler
      _collisions_removal_dataloader_props(props)
      return data_loader.__class__(**props)
  
imports: import random
  from copy import copy
  from hashlib import md5
  from typing import Dict, Iterator, List, Sized
  import numpy
  import torch
  from PIL import Image
  from torch.utils.data import BatchSampler, DataLoader, Sampler
  from deepchecks.vision import VisionData
  from deepchecks.vision.vision_data.utils import object_to_numpy
label_desc: Use image node_id 5 for calling a global function with example usage: get_data_loader_sequential(data_loader, shuffle, n_samples) and returns: data_loader