class_docstr: 将 ``dataset`` 中的数据根据 ``length`` 从长到短进行迭代。在多卡情况下，由于 ``padding`` , 最后一个 ``sample`` 可能是最长
  的那个 ``sample`` 。
  
  :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 seed: 设置的随机数种子
  :param kwargs: fastNLP 内部使用的参数
class_docstr_tok: ["\u5c06","``","dataset","``","\u4e2d\u7684\u6570\u636e\u6839\u636e","``","length","``","\u4ece\u957f\u5230\u77ed\u8fdb\u884c\u8fed\u4ee3\u3002\u5728\u591a\u5361\u60c5\u51b5\u4e0b\uff0c\u7531\u4e8e","``","padding","``",",","\u6700\u540e\u4e00\u4e2a","``","sample","``","\u53ef\u80fd\u662f\u6700\u957f","\u7684\u90a3\u4e2a","``","sample","``","\u3002",":","param","dataset",":","\u5b9e\u73b0\u4e86","__len__","\u65b9\u6cd5\u7684\u6570\u636e\u5bb9\u5668",":","param","length",":","\u6bcf\u6761\u6570\u636e\u7684\u957f\u5ea6\uff1a","*","\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","seed",":","\u8bbe\u7f6e\u7684\u968f\u673a\u6570\u79cd\u5b50",":","param","kwargs",":","fastNLP","\u5185\u90e8\u4f7f\u7528\u7684\u53c2\u6570"]
code: def __iter__(self):
      if self.during_iter:  # 如果发现_during_iter为True，说明之前的还没结束，只有强制重新初始化了
          self.num_consumed_samples = 0
      self.during_iter = True
      indices = self.generate_indices()
  
      if self.pad:
          padding_size = self.total_size - len(indices)
          if padding_size <= len(indices):
              indices += indices[:padding_size]
          else:
              indices += (
                  indices * math.ceil(padding_size / len(indices))
              )[:padding_size]
      else:
          # remove tail of data to make it evenly divisible.
          indices = indices[: self.total_size]
  
      assert len(indices) == self.total_size
  
      # subsample
      indices = indices[self.num_consumed_samples :]
      indices = indices[self.rank : len(indices) : self.num_replicas]
      assert len(indices) == self.num_left_samples
  
      for idx, index in enumerate(indices, start=1):
          self.num_consumed_samples += self.num_replicas
          yield index
      self.during_iter = False
      self.num_consumed_samples = 0
  
imports: from typing import Dict, List, Union, Sequence
  import math
  import numpy
  from fastNLP.core.log import logger
  from fastNLP.core.dataset import DataSet
label_desc: Use image node_id 3 for calling the SortedSampler obj's underlying member method code with example usage: obj.__iter__() without return types