docstr: 测试 set_dist_repro_dataloader 中 dist 为 RandomSampler 时的表现
  此时应该将 batch_sampler.sampler 替换为 dist 对应的 RandomSampler
docstr_tok: ["\u6d4b\u8bd5","set_dist_repro_dataloader","\u4e2d","dist","\u4e3a","RandomSampler","\u65f6\u7684\u8868\u73b0","\u6b64\u65f6\u5e94\u8be5\u5c06","batch_sampler.sampler","\u66ff\u6362\u4e3a","dist","\u5bf9\u5e94\u7684","RandomSampler"]
code: def test_with_dist_sampler(self, shuffle):
      """
      测试 set_dist_repro_dataloader 中 dist 为 RandomSampler 时的表现
      此时应该将 batch_sampler.sampler 替换为 dist 对应的 RandomSampler
      """
      driver = generate_driver(10, 10, device=self.device)
      dataloader = DataLoader(
          self.dataset, batch_size=4, shuffle=not shuffle
      )
      sampler = RandomSampler(self.dataset, shuffle=shuffle)
      replaced_loader = driver.set_dist_repro_dataloader(
          dataloader, sampler, False
      )
  
      assert not (replaced_loader is dataloader)
      assert isinstance(replaced_loader.batch_sampler, BatchSampler)
      assert isinstance(
          replaced_loader.batch_sampler.sampler, RandomSampler
      )
      assert not (
          replaced_loader.batch_sampler is dataloader.batch_sampler
      )
      assert replaced_loader.batch_sampler.sampler is sampler
      assert (
          replaced_loader.batch_sampler.batch_size
          == dataloader.batch_sampler.batch_size
      )
      self.check_distributed_sampler(
          replaced_loader.batch_sampler.sampler
      )
      self.check_set_dist_repro_dataloader(
          driver, dataloader, replaced_loader, shuffle
      )
  
      comm.barrier()
  
imports: import os
  import sys
  import pytest
  from pathlib import Path
  from fastNLP.core.drivers.oneflow_driver.ddp import OneflowDDPDriver
  from fastNLP import prepare_oneflow_dataloader
  from fastNLP.core.samplers import RandomSampler, UnrepeatedSampler, BucketedBatchSampler, UnrepeatedRandomSampler, UnrepeatedSequentialSampler
  from tests.helpers.models.oneflow_model import OneflowNormalModel_Classification_1
  from tests.helpers.datasets.oneflow_data import OneflowNormalDataset, OneflowNormalXYDataset
  from tests.helpers.utils import recover_logger
  from fastNLP.envs.distributed import rank_zero_rm
  from fastNLP import logger
  from fastNLP.core.drivers.oneflow_driver.dist_utils import fastnlp_oneflow_all_gather
  from fastNLP.envs.imports import _NEED_IMPORT_ONEFLOW
label_desc: Use image node_id 4 for calling the TestSetDistReproDataloader obj's underlying member method code with example usage: obj.test_with_dist_sampler(shuffle) without return types