code: def test_2(self):
      data_length = 100
      torch_normal_data = TorchNormalDataset(num_of_data=data_length)
      random_sampler_1 = RandomSampler(
          dataset=torch_normal_data, shuffle=True
      )
  
      iterator = iter(random_sampler_1)
      # 第一轮
      random_sampler_1.set_epoch(0)
      first_epoch = []
      forward_steps = 30
      for _ in range(forward_steps):
          first_epoch.append(next(iterator))
  
      # 先提前保存断点重训的结果;
      state = random_sampler_1.state_dict()
  
      # 保存第一个 epoch 的之后的结果，用于查看断点重训是否正确；
      first_left_data = []
      while True:
          try:
              first_left_data.append(next(iterator))
          except StopIteration:
              break
  
      # 第二轮
      random_sampler_1.set_epoch(1)
      iterator = iter(random_sampler_1)
      second_epoch = []
      for _ in range(forward_steps):
          second_epoch.append(next(iterator))
  
      assert first_epoch != second_epoch
  
      # 重新加载第一轮的状态，查看断点重训是否正确；
      random_sampler_2 = RandomSampler(
          dataset=torch_normal_data, shuffle=True
      )
      random_sampler_2.load_state_dict(state)
      random_sampler_2.set_epoch(0)
      iterator = iter(random_sampler_2)
      re_first_epoch = []
      while True:
          try:
              re_first_epoch.append(next(iterator))
          except StopIteration:
              break
      assert re_first_epoch == first_left_data
  
      # 查看第二轮的结果是否也是和第一次的第二轮完全一致；
      random_sampler_2.set_epoch(1)
      iterator = iter(random_sampler_2)
      re_second_epoch = []
      for _ in range(forward_steps):
          re_second_epoch.append(next(iterator))
      assert re_second_epoch == second_epoch
  
imports: import numpy
  import pytest
  from functools import partial
  from itertools import chain
  from copy import deepcopy
  from fastNLP.core.samplers.reproducible_sampler import RandomSampler, SortedSampler, SequentialSampler
  from tests.helpers.datasets.torch_data import TorchNormalDataset
label_desc: Use image node_id 2 for calling the TestRandomSampler obj's underlying member method code with example usage: obj.test_2() without return types