docstr: 测试是否能够正确地恢复使用过的（forward）数据
  
  :return:
docstr_tok: ["\u6d4b\u8bd5\u662f\u5426\u80fd\u591f\u6b63\u786e\u5730\u6062\u590d\u4f7f\u7528\u8fc7\u7684\uff08forward\uff09\u6570\u636e",":","return",":"]
code: def test_multi_save_load(
      self, shuffle, drop_last, pad, num_samples, num_replicas
  ):
      """
      测试是否能够正确地恢复使用过的（forward）数据
  
      :return:
      """
      batch_size = 6
      num_batch_per_bucket = 10
      dataset = DatasetWithVaryLength(num_of_data=num_samples)
      samplers = []
      num_consumed_samples_array = list(
          range(0, num_samples + num_replicas, num_replicas)
      )
      for i in range(num_replicas):
          sampler = BucketedBatchSampler(
              dataset,
              length=dataset.data,
              batch_size=batch_size,
              num_batch_per_bucket=num_batch_per_bucket,
              shuffle=shuffle,
              drop_last=drop_last,
          )
  
          sampler.set_distributed(
              num_replicas=num_replicas, rank=i, pad=pad
          )
          samplers.append(sampler)
      count = 0
      already_seen_sets = [set()]
      already_seen_set = set()
      for batchs in zip(*samplers):
          batch = chain(*batchs)
          already_seen_set.update(batch)
          already_seen_sets.append(deepcopy(already_seen_set))
          count += 1
          if count > 3:
              break
      states = samplers[0].state_dict()
      for i in range(len(already_seen_sets)):
          states["num_consumed_samples"] = num_consumed_samples_array[i]
          sampler = BucketedBatchSampler(
              dataset,
              length=dataset.data,
              batch_size=batch_size + 1,
              num_batch_per_bucket=num_batch_per_bucket,
              shuffle=shuffle,
              drop_last=drop_last,
          )
          sampler.set_epoch(0)
          already_seen_set = deepcopy(already_seen_sets[i])
          for batch in sampler:
              already_seen_set.update(batch)
          assert (
              len(already_seen_set) == len(dataset)
              if drop_last is False
              else len(already_seen_set) <= len(dataset)
          )
  
      # 测试保存之后再次保存
      sampler = BucketedBatchSampler(
          dataset,
          length=dataset.data,
          batch_size=batch_size + 1,
          num_batch_per_bucket=num_batch_per_bucket,
          shuffle=shuffle,
          drop_last=drop_last,
      )
      sampler.set_epoch(0)
      states["num_consumed_samples"] = num_consumed_samples_array[2]
      if len(already_seen_sets) < 3:
          return
      already_seen_set = already_seen_sets[2]
      count = 0
      for batch in sampler:
          already_seen_set.update(batch)
          count += 1
          if count > 6:
              break
  
      states = sampler.state_dict()
      num_consumed_samples_array = list(range(len(dataset)))
      states["num_consumed_samples"] = num_consumed_samples_array[count]
      sampler = BucketedBatchSampler(
          dataset,
          length=dataset.data,
          batch_size=batch_size // 2,
          num_batch_per_bucket=num_batch_per_bucket,
          shuffle=shuffle,
          drop_last=drop_last,
      )
      sampler.load_state_dict(states)
      sampler.set_epoch(0)
      for batch in sampler:
          already_seen_set.update(batch)
  
      assert (
          len(already_seen_set) == len(dataset)
          if drop_last is False
          else len(already_seen_set) <= len(dataset)
      )
  
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 5 for calling the TestBucketedBatchSampler obj's underlying member method code with example usage: obj.test_multi_save_load(shuffle, drop_last, pad, num_samples, num_replicas) without return types