code: def test_2(self):
      # 测试新的一轮的 index list 是重新生成的，而不是沿用上一轮的；
      before_batch_size = 7
      sampler = NormalSampler(num_of_data=100)
      # 开启 shuffle，来检验断点重训后的第二轮的 index list 是不是重新生成的；
      reproduce_batch_sampler = ReproduceBatchSampler(
          sampler, before_batch_size, drop_last=False
      )
  
      # 将一轮的所有数据保存下来，看是否恢复的是正确的；
      all_supposed_data = []
      forward_steps = 3
      iter_dataloader = iter(reproduce_batch_sampler)
      for _ in range(forward_steps):
          all_supposed_data.extend(next(iter_dataloader))
  
      # 1. 保存状态
      state = reproduce_batch_sampler.state_dict()
  
      # 2. 断点重训，重新生成一个 dataloader；
      # 不改变 batch_size；
      sampler = NormalSampler(num_of_data=100, shuffle=True)
      reproduce_batch_sampler = ReproduceBatchSampler(
          sampler, before_batch_size, drop_last=False
      )
      reproduce_batch_sampler.load_state_dict(state)
  
      # 先把这一轮的数据过完；
      pre_index_list = reproduce_batch_sampler.state_dict()[
          "index_list"
      ]
      iter_dataloader = iter(reproduce_batch_sampler)
      while True:
          try:
              all_supposed_data.extend(next(iter_dataloader))
          except StopIteration:
              break
      assert all_supposed_data == list(pre_index_list)
  
      # 重新开启新的一轮；
      for _ in range(3):
          iter_dataloader = iter(reproduce_batch_sampler)
          res = []
          while True:
              try:
                  res.extend(next(iter_dataloader))
              except StopIteration:
                  break
          assert res != all_supposed_data
  
imports: import numpy
  import pytest
  from itertools import chain
  from copy import deepcopy
  from array import array
  from tests.helpers.datasets.normal_data import NormalSampler, NormalBatchSampler
  from fastNLP.core.samplers import ReproduceBatchSampler, BucketedBatchSampler, RandomBatchSampler
label_desc: Use image node_id 2 for calling the TestReproducibleBatchSampler obj's underlying member method code with example usage: obj.test_2() without return types