code: def test_multi(self, pad, num_replicas, num_of_data):
      data = DatasetWithVaryLength(num_of_data=num_of_data)
      samplers = []
      for i in range(num_replicas):
          sampler = SortedSampler(dataset=data, length=data.data)
          sampler.set_distributed(num_replicas, rank=i, pad=pad)
          samplers.append(sampler)
  
      # 保证顺序是没乱的
      already_seen_index = set()
      for sampler in samplers:
          larger_count = 0  # 这里为 0 就可以，因为最后补充的index一定是比较大的数。
          prev_index = float("inf")
          cur_set = set()
          seen_in_other_rank = 0
          for index in sampler:
              seen_in_other_rank += int(
                  index in already_seen_index
              )  # 不同的卡不交叉
              cur_set.add(index)
              larger_count += int(index <= prev_index)
              prev_index = index
          assert larger_count + 1 >= len(
              sampler
          )  # 除了最后一个可能乱掉，其它都必须要保持这个顺序
          assert (
              seen_in_other_rank <= 1
              if pad
              else seen_in_other_rank == 0
          )
          already_seen_index.update(cur_set)
  
      indexes = list(chain(*samplers))
      indexes = set(indexes)
      if pad:
          assert indexes == set(range(num_of_data))
      else:
          assert len(indexes) <= num_of_data
  
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 TestSortedSampler obj's underlying member method code with example usage: obj.test_multi(pad, num_replicas, num_of_data) without return types