class_docstr: 将 ``dataset`` 中的数据根据 ``length`` 从长到短进行迭代，并且保证在多卡场景下数据不重复。
  
  .. note::
  
      本 Sampler 可能导致各个机器上的batch 数量不完全一致。
  
  :param dataset: 实现了 __len__ 方法的数据容器
  :param length: 每条数据的长度
  
      * 为 ``List[int]`` 时
       应当与 dataset 有一样的长度，表示 dataset 中每个元素的数量；
      * 为 ``str`` 时
        仅当传入的 ``dataset`` 是 :class:`~fastNLP.DataSet` 时，允许传入 `str` ，该 `str` 将被认为是 ``dataset`` 中的
        ``field`` 。若 field 中的元素为 ``int``，则认为该值是 sample 的长度；若不为 ``int`` ，则尝试使用 ``len`` 方法
        获取该 ``field`` 中每个元素的长度；
  
  :param kwargs: fastNLP 内部使用的参数
class_docstr_tok: ["\u5c06","``","dataset","``","\u4e2d\u7684\u6570\u636e\u6839\u636e","``","length","``","\u4ece\u957f\u5230\u77ed\u8fdb\u884c\u8fed\u4ee3\uff0c\u5e76\u4e14\u4fdd\u8bc1\u5728\u591a\u5361\u573a\u666f\u4e0b\u6570\u636e\u4e0d\u91cd\u590d\u3002","..","note",":",":","\u672c","Sampler","\u53ef\u80fd\u5bfc\u81f4\u5404\u4e2a\u673a\u5668\u4e0a\u7684batch","\u6570\u91cf\u4e0d\u5b8c\u5168\u4e00\u81f4\u3002",":","param","dataset",":","\u5b9e\u73b0\u4e86","__len__","\u65b9\u6cd5\u7684\u6570\u636e\u5bb9\u5668",":","param","length",":","\u6bcf\u6761\u6570\u636e\u7684\u957f\u5ea6","*","\u4e3a","``","List","[","int","]","``","\u65f6","\u5e94\u5f53\u4e0e","dataset","\u6709\u4e00\u6837\u7684\u957f\u5ea6\uff0c\u8868\u793a","dataset","\u4e2d\u6bcf\u4e2a\u5143\u7d20\u7684\u6570\u91cf\uff1b","*","\u4e3a","``","str","``","\u65f6","\u4ec5\u5f53\u4f20\u5165\u7684","``","dataset","``","\u662f",":","class",":","`","~fastNLP.DataSet","`","\u65f6\uff0c\u5141\u8bb8\u4f20\u5165","`","str","`","\uff0c\u8be5","`","str","`","\u5c06\u88ab\u8ba4\u4e3a\u662f","``","dataset","``","\u4e2d\u7684","``","field","``","\u3002\u82e5","field","\u4e2d\u7684\u5143\u7d20\u4e3a","``","int","``","\uff0c\u5219\u8ba4\u4e3a\u8be5\u503c\u662f","sample","\u7684\u957f\u5ea6\uff1b\u82e5\u4e0d\u4e3a","``","int","``","\uff0c\u5219\u5c1d\u8bd5\u4f7f\u7528","``","len","``","\u65b9\u6cd5","\u83b7\u53d6\u8be5","``","field","``","\u4e2d\u6bcf\u4e2a\u5143\u7d20\u7684\u957f\u5ea6\uff1b",":","param","kwargs",":","fastNLP","\u5185\u90e8\u4f7f\u7528\u7684\u53c2\u6570"]
code: def __init__(self, dataset, length: Union[str, List], **kwargs):
      kwargs["shuffle"] = False
      kwargs["seed"] = 0
      super().__init__(dataset=dataset, **kwargs)
      if isinstance(dataset, DataSet) and isinstance(length, str):
          length = dataset.get_field(length).content
          if not isinstance(length[0], int):
              length = list(map(len, length))
      else:
          assert len(length) == len(dataset), (
              "When the dataset is not fastNLP.DataSet, "
              "the length parameter can only be List[int]"
          )
  
      assert len(length) == len(
          dataset
      ), "The length of `data` and `length` should be equal."
  
      length = np.array(length, dtype=int)  # 按照长到短排列的序号。
      self.sorted_indices = np.argsort(length)[::-1].tolist()
  
imports: from typing import List, Union
  from fastNLP.core.dataset import DataSet
  import numpy
label_desc: Use image node_id 1 to create a new UnrepeatedSortedSampler object from inherited base classes: UnrepeatedRandomSampler with example: obj = UnrepeatedSortedSampler(dataset, length)