class_docstr: 首先按照 ``sample`` 的长度排序，然后按照 *batch_size*num_batch_per_bucket* 为一个桶的大小，``sample`` 只会在这个桶内进行组
  合，这样每个 ``batch`` 中的 ``padding`` 数量会比较少 （因为桶内的数据的长度都接近）。
  
  :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 batch_size: 每个 batch 的大小
  :param num_batch_per_bucket: 多少个 ``batch`` 组成一个桶，数据只会在一个桶内进行 ``shuffle`` 。
  :param shuffle: 如果为 True，将不进行 ``shuffle``，实际上数据会以从长到短的方式输出。
  :param drop_last: 如果最后一个 `batch` 的 ``sample`` 数量无法凑齐 ``batch_size`` 这么多，是否需要丢掉。
  :param seed: 设置的随机数种子
  :param kwargs: fastNLP 保留使用
class_docstr_tok: ["\u9996\u5148\u6309\u7167","``","sample","``","\u7684\u957f\u5ea6\u6392\u5e8f\uff0c\u7136\u540e\u6309\u7167","*","batch_size","*","num_batch_per_bucket","*","\u4e3a\u4e00\u4e2a\u6876\u7684\u5927\u5c0f\uff0c","``","sample","``","\u53ea\u4f1a\u5728\u8fd9\u4e2a\u6876\u5185\u8fdb\u884c\u7ec4","\u5408\uff0c\u8fd9\u6837\u6bcf\u4e2a","``","batch","``","\u4e2d\u7684","``","padding","``","\u6570\u91cf\u4f1a\u6bd4\u8f83\u5c11","\uff08\u56e0\u4e3a\u6876\u5185\u7684\u6570\u636e\u7684\u957f\u5ea6\u90fd\u63a5\u8fd1\uff09\u3002",":","param","dataset",":","\u5b9e\u73b0\u4e86","__len__","\u65b9\u6cd5\u7684\u6570\u636e\u5bb9\u5668\u3002",":","param","length",":","\u6bcf\u6761\u6570\u636e\u7684\u957f\u5ea6\u3002","*","\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\u3002",":","param","batch_size",":","\u6bcf\u4e2a","batch","\u7684\u5927\u5c0f",":","param","num_batch_per_bucket",":","\u591a\u5c11\u4e2a","``","batch","``","\u7ec4\u6210\u4e00\u4e2a\u6876\uff0c\u6570\u636e\u53ea\u4f1a\u5728\u4e00\u4e2a\u6876\u5185\u8fdb\u884c","``","shuffle","``","\u3002",":","param","shuffle",":","\u5982\u679c\u4e3a","True\uff0c\u5c06\u4e0d\u8fdb\u884c","``","shuffle","``","\uff0c\u5b9e\u9645\u4e0a\u6570\u636e\u4f1a\u4ee5\u4ece\u957f\u5230\u77ed\u7684\u65b9\u5f0f\u8f93\u51fa\u3002",":","param","drop_last",":","\u5982\u679c\u6700\u540e\u4e00\u4e2a","`","batch","`","\u7684","``","sample","``","\u6570\u91cf\u65e0\u6cd5\u51d1\u9f50","``","batch_size","``","\u8fd9\u4e48\u591a\uff0c\u662f\u5426\u9700\u8981\u4e22\u6389\u3002",":","param","seed",":","\u8bbe\u7f6e\u7684\u968f\u673a\u6570\u79cd\u5b50",":","param","kwargs",":","fastNLP","\u4fdd\u7559\u4f7f\u7528"]
docstr: 当前迭代还有多少个 sample 结束，表示的是 **当前 rank** 的还剩多少。
docstr_tok: ["\u5f53\u524d\u8fed\u4ee3\u8fd8\u6709\u591a\u5c11\u4e2a","sample","\u7ed3\u675f\uff0c\u8868\u793a\u7684\u662f","*","*","\u5f53\u524d","rank","*","*","\u7684\u8fd8\u5269\u591a\u5c11\u3002"]
code: def num_left_samples(self):
      """
      当前迭代还有多少个 sample 结束，表示的是 **当前 rank** 的还剩多少。
      """
      num_consumed_samples = self.num_consumed_samples
      return (
          math.ceil(
              (self.num_samples - num_consumed_samples)
              / self.num_replicas
          )
          if self.pad
          else math.floor(
              (
                  (self.num_samples - num_consumed_samples)
                  / self.num_replicas
              )
          )
      )
  
imports: import os
  import math
  from copy import deepcopy
  from typing import Dict, Union, List
  from itertools import chain
  import numpy
  from fastNLP.core.dataset import DataSet
  from fastNLP.core.log import logger
  from .utils import create_array
  from abc import abstractmethod
label_desc: Use image node_id 4 for calling the BucketedBatchSampler obj's underlying member method code with example usage: obj.num_left_samples() and returns: unknown