def METHOD_NAME(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)