class_docstr: 针对以下四种情况提供的 ``MixDataLoader``， 目前只支持 **pytorch** 框架的版本， 其中 mode 的取值范围为 ``['sequential', 'mix', 'polling', 'Sampler']``:
  
      * 当 mode 为 ``'sequential'`` 时，``MixDataLoader``  将 ``datasets`` 的序列或者字典视为一个混合大数据集， 按照 datasets 数据集序列或者字典的顺序一个
        接一个的 sample 完所有数据。
      * 当 mode 为 ``'mix'`` 时， ``MixDataLoader``  将 ``datasets`` 的序列或者字典视为一个混合大数据集， 然后根据用户输入的 idx 序列随机 sample
        混合数据集 datasets 的数据组成一个 batch 序列返回。
      * 当 mode 为 ``'polling'`` 时， ``MixDataLoader`` 按照 ``datasets`` 数据集的顺序， 先从第一个数据集采样一个 batch 的数据返回，
        再从第二数据集采样一个 batch 数据返回， 直至最后一个数据集采样一个 batch 数据返回后再从第一个数据采样第二个 batch 数据返回，直至所有的数据集都被轮询地的采样完。
      * 当 mode 为 ``'Sampler'`` 时， 该 Sampler 是实现 __iter__() 的实例化对象， 其功能是每次 iter 时返回一个 batch 序列， 其类型为 List[int];
        且 Sampler 必须将输入的 datasets 视为一个混合大数据集， 其 index 范围为 ``0<idx<len(datasets[0])+...+len(datasets[x])``, 然后参数
        ``sampler``, ``drop_last``, ``ds_ratio`` 均无效。
  
  :param datasets: 实现了 __getitem__() 和 __len__() 对象的序列或者字典。
  :param mode: ``mode`` 控制 ``MixDataLoader`` 运行模式。 ``mode`` 的取值范围为 ``['sequential', 'mix', 'polling', 'Sampler']``，每种模式的详细功能见上文。
  :param collate_fn: 用于从 dataset 取到的一个 batch 数据进行打包处理的 Callable 函数。 其取值可以为 ``['auto', Callable, List[Callable], Dict[str, Callable]]``:
  
      * collate_fn 为 ``'auto'`` 时, ``MixDataLoader``  datasets 序列或者dict 初始化一个 :class:`~fastNLP.core.collators.Collator`  作为其默认值，
        需要注意的是只有当 datasets 包含的所以 dataset 的数据都为 ``List`` 或者 ``Dict`` 类型时才能使用。否则只能用户自己定义 collate_fn 。
      * collate_fn 为  :class:`Callable` 时， 该 collate_fn 会被 datasets 序列或者dict 的所有数据所共享。该 Callable 函数应当接受一个 batch 参数作为输入，
        batch 是一个 List 对象且 List 中的每一条数据都是 dataset 的一条数据；该 Callable 函数还应当返回一个对象。
      * collate_fn 为 ``Dict[str, Callable]`` 时， datasets 的 key 必须和 callable_fn 的 key 一致。 ``MixDataLoader`` 会将 ``collate_fn[key]``
        用到 ``datasets[key]`` 的数据集上。 ``collate_fn[key]`` 是一个 Callable 对象。
  
  
  :param sampler: 实现了 __len__() 和 __iter__() 的实例化对象，其 __iter__() 方法每次都会返回 dataset 的一个下标 index ，其取值范围为
      ``[None, str, Dict[str, Sampler]]``:
  
      * sampler 为 ``None`` 时， ``MixDataLoader`` 默认初始化 **pytorch** 的 ``SequentialSampler`` 作为默认值。其功能时顺序返回 dataset 的下标。
      * sampler 为 ``str`` 时， sampler 选择范围为 ``[rand, seq]``。当 sampler 为 ``rand`` 时，``MixDataLoader`` 默认初始化 **pytorch** 的  ``RandomSampler``
        作为默认值， 其功能时随机采样 dataset 的下标并返回。 当 sampler 为 ``seq`` 时， ``MixDataLoader`` 默认初始化 **pytorch** 的 ``SequentialSampler`` 作为默认值。其功能时顺序返回 dataset 的下标。
      * sampler 为 ``Dict[str, Sampler]`` 时， ``Sampler`` 为用户定义的实现了 __len__() 和 __iter__() 的实例化对象。 其每次 iter 必须返回一个 int 下标。
        Dict 的 str 必须和 datasets 的 key 一致。 也即是 ``Dict[str, Sampler]`` 为 datasets 字典的每个 dataset 初始化了一个 Sampler。
  
  :param num_workers: 当 ``num_workers > 0`` 时, ``MixDataLoader`` 会开启 ``num_workers`` 个子进程来处理数据， 可以加快数据处理速度，但同时
      也消耗大量内存。 当 ``num_workers=0`` 时， 不开启子进程。 默认为 ``0``。
  :param batch_size: 批次大小，默认为 ``16`` 且当 batch_sampler 为 ``None`` 有效。 且 datasets 上所有 dataset 的 batch_size 一致。
  :param drop_last: 当 ``drop_last=True`` 时，``MixDataLoader`` 会扔掉 datasets 中 每个 dataset 最后一个长度小于 ``batch_size`` 的 batch 数据;
      若 ``drop_last=False`` , 则会返回该 batch 数据。 默认为 ``False`` 。
  :param ds_ratio: ``ds_ratio`` 是控制 datasets 怎么组成一个混合大数据集的重要参数， 其取值为 ``[None, 'truncate_to_least', 'pad_to_most', List[float], Dict[str, float]]``:
  
      * ds_ratio 为 ``None``, datasets 数据集序列或字典不进行数据扩充处理。
      * ds_ratio 为 ``'truncate_to_least'``, datasets 数据集序列或字典会计算得到 datasets序列中 dataset 最断长度 ``mix_len``， 其他数据集会被切断
        到最短长度 ``mix_len``。这种切断不是物理上切断，``MixDataLoader`` 会根据 sampler 不同来采样数据集到指定的最短长度 ``mix_len``。
      * ds_ratio 为 ``'pad_to_most'``, datasets 数据集序列或字典会计算得到 datasets序列中 dataset 最大长度 ``max_len``, 其他其他数据集会扩充
        到最大长度 ``mix_len``。这种扩充不是物理上扩充， ``MixDataLoader`` 会根据 sampler 不同来重采样 dataset 到指定的最大长度 ``max_len``。
      * ds_ratio 为 ``Dict[str, float]`` 时， datasets 类型也必须为 ``Dict[str, DataSet]``, 其 key 一一对应。 ds_ratio 的 value 是任意大于 0 的浮点数，
        代表着 datasets 的 value 数据进行扩充或者缩减的倍数。
class_docstr_tok: ["\u9488\u5bf9\u4ee5\u4e0b\u56db\u79cd\u60c5\u51b5\u63d0\u4f9b\u7684","``","MixDataLoader","``","\uff0c","\u76ee\u524d\u53ea\u652f\u6301","*","*","pytorch","*","*","\u6846\u67b6\u7684\u7248\u672c\uff0c","\u5176\u4e2d","mode","\u7684\u53d6\u503c\u8303\u56f4\u4e3a","``","[","'sequential","'",",","'mix","'",",","'polling","'",",","'Sampler","'","]","``",":","*","\u5f53","mode","\u4e3a","``","'sequential","'","``","\u65f6\uff0c","``","MixDataLoader","``","\u5c06","``","datasets","``","\u7684\u5e8f\u5217\u6216\u8005\u5b57\u5178\u89c6\u4e3a\u4e00\u4e2a\u6df7\u5408\u5927\u6570\u636e\u96c6\uff0c","\u6309\u7167","datasets","\u6570\u636e\u96c6\u5e8f\u5217\u6216\u8005\u5b57\u5178\u7684\u987a\u5e8f\u4e00\u4e2a","\u63a5\u4e00\u4e2a\u7684","sample","\u5b8c\u6240\u6709\u6570\u636e\u3002","*","\u5f53","mode","\u4e3a","``","'mix","'","``","\u65f6\uff0c","``","MixDataLoader","``","\u5c06","``","datasets","``","\u7684\u5e8f\u5217\u6216\u8005\u5b57\u5178\u89c6\u4e3a\u4e00\u4e2a\u6df7\u5408\u5927\u6570\u636e\u96c6\uff0c","\u7136\u540e\u6839\u636e\u7528\u6237\u8f93\u5165\u7684","idx","\u5e8f\u5217\u968f\u673a","sample","\u6df7\u5408\u6570\u636e\u96c6","datasets","\u7684\u6570\u636e\u7ec4\u6210\u4e00\u4e2a","batch","\u5e8f\u5217\u8fd4\u56de\u3002","*","\u5f53","mode","\u4e3a","``","'polling","'","``","\u65f6\uff0c","``","MixDataLoader","``","\u6309\u7167","``","datasets","``","\u6570\u636e\u96c6\u7684\u987a\u5e8f\uff0c","\u5148\u4ece\u7b2c\u4e00\u4e2a\u6570\u636e\u96c6\u91c7\u6837\u4e00\u4e2a","batch","\u7684\u6570\u636e\u8fd4\u56de\uff0c","\u518d\u4ece\u7b2c\u4e8c\u6570\u636e\u96c6\u91c7\u6837\u4e00\u4e2a","batch","\u6570\u636e\u8fd4\u56de\uff0c","\u76f4\u81f3\u6700\u540e\u4e00\u4e2a\u6570\u636e\u96c6\u91c7\u6837\u4e00\u4e2a","batch","\u6570\u636e\u8fd4\u56de\u540e\u518d\u4ece\u7b2c\u4e00\u4e2a\u6570\u636e\u91c7\u6837\u7b2c\u4e8c\u4e2a","batch","\u6570\u636e\u8fd4\u56de\uff0c\u76f4\u81f3\u6240\u6709\u7684\u6570\u636e\u96c6\u90fd\u88ab\u8f6e\u8be2\u5730\u7684\u91c7\u6837\u5b8c\u3002","*","\u5f53","mode","\u4e3a","``","'Sampler","'","``","\u65f6\uff0c","\u8be5","Sampler","\u662f\u5b9e\u73b0","__iter__","(",")","\u7684\u5b9e\u4f8b\u5316\u5bf9\u8c61\uff0c","\u5176\u529f\u80fd\u662f\u6bcf\u6b21","iter","\u65f6\u8fd4\u56de\u4e00\u4e2a","batch","\u5e8f\u5217\uff0c","\u5176\u7c7b\u578b\u4e3a","List","[","int","]",";","\u4e14","Sampler","\u5fc5\u987b\u5c06\u8f93\u5165\u7684","datasets","\u89c6\u4e3a\u4e00\u4e2a\u6df7\u5408\u5927\u6570\u636e\u96c6\uff0c","\u5176","index","\u8303\u56f4\u4e3a","``","0","<","idx","<","len","(","datasets","[","0","]",")","+","...","+len","(","datasets","[","x","]",")","``",",","\u7136\u540e\u53c2\u6570","``","sampler","``",",","``","drop_last","``",",","``","ds_ratio","``","\u5747\u65e0\u6548\u3002",":","param","datasets",":","\u5b9e\u73b0\u4e86","__getitem__","(",")","\u548c","__len__","(",")","\u5bf9\u8c61\u7684\u5e8f\u5217\u6216\u8005\u5b57\u5178\u3002",":","param","mode",":","``","mode","``","\u63a7\u5236","``","MixDataLoader","``","\u8fd0\u884c\u6a21\u5f0f\u3002","``","mode","``","\u7684\u53d6\u503c\u8303\u56f4\u4e3a","``","[","'sequential","'",",","'mix","'",",","'polling","'",",","'Sampler","'","]","``","\uff0c\u6bcf\u79cd\u6a21\u5f0f\u7684\u8be6\u7ec6\u529f\u80fd\u89c1\u4e0a\u6587\u3002",":","param","collate_fn",":","\u7528\u4e8e\u4ece","dataset","\u53d6\u5230\u7684\u4e00\u4e2a","batch","\u6570\u636e\u8fdb\u884c\u6253\u5305\u5904\u7406\u7684","Callable","\u51fd\u6570\u3002","\u5176\u53d6\u503c\u53ef\u4ee5\u4e3a","``","[","'auto","'",",","Callable",",","List","[","Callable","]",",","Dict","[","str",",","Callable","]","]","``",":","*","collate_fn","\u4e3a","``","'auto","'","``","\u65f6",",","``","MixDataLoader","``","datasets","\u5e8f\u5217\u6216\u8005dict","\u521d\u59cb\u5316\u4e00\u4e2a",":","class",":","`","~fastNLP.core.collators.Collator","`","\u4f5c\u4e3a\u5176\u9ed8\u8ba4\u503c\uff0c","\u9700\u8981\u6ce8\u610f\u7684\u662f\u53ea\u6709\u5f53","datasets","\u5305\u542b\u7684\u6240\u4ee5","dataset","\u7684\u6570\u636e\u90fd\u4e3a","``","List","``","\u6216\u8005","``","Dict","``","\u7c7b\u578b\u65f6\u624d\u80fd\u4f7f\u7528\u3002\u5426\u5219\u53ea\u80fd\u7528\u6237\u81ea\u5df1\u5b9a\u4e49","collate_fn","\u3002","*","collate_fn","\u4e3a",":","class",":","`","Callable","`","\u65f6\uff0c","\u8be5","collate_fn","\u4f1a\u88ab","datasets","\u5e8f\u5217\u6216\u8005dict","\u7684\u6240\u6709\u6570\u636e\u6240\u5171\u4eab\u3002\u8be5","Callable","\u51fd\u6570\u5e94\u5f53\u63a5\u53d7\u4e00\u4e2a","batch","\u53c2\u6570\u4f5c\u4e3a\u8f93\u5165\uff0c","batch","\u662f\u4e00\u4e2a","List","\u5bf9\u8c61\u4e14","List","\u4e2d\u7684\u6bcf\u4e00\u6761\u6570\u636e\u90fd\u662f","dataset","\u7684\u4e00\u6761\u6570\u636e\uff1b\u8be5","Callable","\u51fd\u6570\u8fd8\u5e94\u5f53\u8fd4\u56de\u4e00\u4e2a\u5bf9\u8c61\u3002","*","collate_fn","\u4e3a","``","Dict","[","str",",","Callable","]","``","\u65f6\uff0c","datasets","\u7684","key","\u5fc5\u987b\u548c","callable_fn","\u7684","key","\u4e00\u81f4\u3002","``","MixDataLoader","``","\u4f1a\u5c06","``","collate_fn","[","key","]","``","\u7528\u5230","``","datasets","[","key","]","``","\u7684\u6570\u636e\u96c6\u4e0a\u3002","``","collate_fn","[","key","]","``","\u662f\u4e00\u4e2a","Callable","\u5bf9\u8c61\u3002",":","param","sampler",":","\u5b9e\u73b0\u4e86","__len__","(",")","\u548c","__iter__","(",")","\u7684\u5b9e\u4f8b\u5316\u5bf9\u8c61\uff0c\u5176","__iter__","(",")","\u65b9\u6cd5\u6bcf\u6b21\u90fd\u4f1a\u8fd4\u56de","dataset","\u7684\u4e00\u4e2a\u4e0b\u6807","index","\uff0c\u5176\u53d6\u503c\u8303\u56f4\u4e3a","``","[","None",",","str",",","Dict","[","str",",","Sampler","]","]","``",":","*","sampler","\u4e3a","``","None","``","\u65f6\uff0c","``","MixDataLoader","``","\u9ed8\u8ba4\u521d\u59cb\u5316","*","*","pytorch","*","*","\u7684","``","SequentialSampler","``","\u4f5c\u4e3a\u9ed8\u8ba4\u503c\u3002\u5176\u529f\u80fd\u65f6\u987a\u5e8f\u8fd4\u56de","dataset","\u7684\u4e0b\u6807\u3002","*","sampler","\u4e3a","``","str","``","\u65f6\uff0c","sampler","\u9009\u62e9\u8303\u56f4\u4e3a","``","[","rand",",","seq","]","``","\u3002\u5f53","sampler","\u4e3a","``","rand","``","\u65f6\uff0c","``","MixDataLoader","``","\u9ed8\u8ba4\u521d\u59cb\u5316","*","*","pytorch","*","*","\u7684","``","RandomSampler","``","\u4f5c\u4e3a\u9ed8\u8ba4\u503c\uff0c","\u5176\u529f\u80fd\u65f6\u968f\u673a\u91c7\u6837","dataset","\u7684\u4e0b\u6807\u5e76\u8fd4\u56de\u3002","\u5f53","sampler","\u4e3a","``","seq","``","\u65f6\uff0c","``","MixDataLoader","``","\u9ed8\u8ba4\u521d\u59cb\u5316","*","*","pytorch","*","*","\u7684","``","SequentialSampler","``","\u4f5c\u4e3a\u9ed8\u8ba4\u503c\u3002\u5176\u529f\u80fd\u65f6\u987a\u5e8f\u8fd4\u56de","dataset","\u7684\u4e0b\u6807\u3002","*","sampler","\u4e3a","``","Dict","[","str",",","Sampler","]","``","\u65f6\uff0c","``","Sampler","``","\u4e3a\u7528\u6237\u5b9a\u4e49\u7684\u5b9e\u73b0\u4e86","__len__","(",")","\u548c","__iter__","(",")","\u7684\u5b9e\u4f8b\u5316\u5bf9\u8c61\u3002","\u5176\u6bcf\u6b21","iter","\u5fc5\u987b\u8fd4\u56de\u4e00\u4e2a","int","\u4e0b\u6807\u3002","Dict","\u7684","str","\u5fc5\u987b\u548c","datasets","\u7684","key","\u4e00\u81f4\u3002","\u4e5f\u5373\u662f","``","Dict","[","str",",","Sampler","]","``","\u4e3a","datasets","\u5b57\u5178\u7684\u6bcf\u4e2a","dataset","\u521d\u59cb\u5316\u4e86\u4e00\u4e2a","Sampler\u3002",":","param","num_workers",":","\u5f53","``","num_workers",">","0","``","\u65f6",",","``","MixDataLoader","``","\u4f1a\u5f00\u542f","``","num_workers","``","\u4e2a\u5b50\u8fdb\u7a0b\u6765\u5904\u7406\u6570\u636e\uff0c","\u53ef\u4ee5\u52a0\u5feb\u6570\u636e\u5904\u7406\u901f\u5ea6\uff0c\u4f46\u540c\u65f6","\u4e5f\u6d88\u8017\u5927\u91cf\u5185\u5b58\u3002","\u5f53","``","num_workers=0","``","\u65f6\uff0c","\u4e0d\u5f00\u542f\u5b50\u8fdb\u7a0b\u3002","\u9ed8\u8ba4\u4e3a","``","0","``","\u3002",":","param","batch_size",":","\u6279\u6b21\u5927\u5c0f\uff0c\u9ed8\u8ba4\u4e3a","``","16","``","\u4e14\u5f53","batch_sampler","\u4e3a","``","None","``","\u6709\u6548\u3002","\u4e14","datasets","\u4e0a\u6240\u6709","dataset","\u7684","batch_size","\u4e00\u81f4\u3002",":","param","drop_last",":","\u5f53","``","drop_last=True","``","\u65f6\uff0c","``","MixDataLoader","``","\u4f1a\u6254\u6389","datasets","\u4e2d","\u6bcf\u4e2a","dataset","\u6700\u540e\u4e00\u4e2a\u957f\u5ea6\u5c0f\u4e8e","``","batch_size","``","\u7684","batch","\u6570\u636e",";","\u82e5","``","drop_last=False","``",",","\u5219\u4f1a\u8fd4\u56de\u8be5","batch","\u6570\u636e\u3002","\u9ed8\u8ba4\u4e3a","``","False","``","\u3002",":","param","ds_ratio",":","``","ds_ratio","``","\u662f\u63a7\u5236","datasets","\u600e\u4e48\u7ec4\u6210\u4e00\u4e2a\u6df7\u5408\u5927\u6570\u636e\u96c6\u7684\u91cd\u8981\u53c2\u6570\uff0c","\u5176\u53d6\u503c\u4e3a","``","[","None",",","'truncate_to_least","'",",","'pad_to_most","'",",","List","[","float","]",",","Dict","[","str",",","float","]","]","``",":","*","ds_ratio","\u4e3a","``","None","``",",","datasets","\u6570\u636e\u96c6\u5e8f\u5217\u6216\u5b57\u5178\u4e0d\u8fdb\u884c\u6570\u636e\u6269\u5145\u5904\u7406\u3002","*","ds_ratio","\u4e3a","``","'truncate_to_least","'","``",",","datasets","\u6570\u636e\u96c6\u5e8f\u5217\u6216\u5b57\u5178\u4f1a\u8ba1\u7b97\u5f97\u5230","datasets\u5e8f\u5217\u4e2d","dataset","\u6700\u65ad\u957f\u5ea6","``","mix_len","``","\uff0c","\u5176\u4ed6\u6570\u636e\u96c6\u4f1a\u88ab\u5207\u65ad","\u5230\u6700\u77ed\u957f\u5ea6","``","mix_len","``","\u3002\u8fd9\u79cd\u5207\u65ad\u4e0d\u662f\u7269\u7406\u4e0a\u5207\u65ad\uff0c","``","MixDataLoader","``","\u4f1a\u6839\u636e","sampler","\u4e0d\u540c\u6765\u91c7\u6837\u6570\u636e\u96c6\u5230\u6307\u5b9a\u7684\u6700\u77ed\u957f\u5ea6","``","mix_len","``","\u3002","*","ds_ratio","\u4e3a","``","'pad_to_most","'","``",",","datasets","\u6570\u636e\u96c6\u5e8f\u5217\u6216\u5b57\u5178\u4f1a\u8ba1\u7b97\u5f97\u5230","datasets\u5e8f\u5217\u4e2d","dataset","\u6700\u5927\u957f\u5ea6","``","max_len","``",",","\u5176\u4ed6\u5176\u4ed6\u6570\u636e\u96c6\u4f1a\u6269\u5145","\u5230\u6700\u5927\u957f\u5ea6","``","mix_len","``","\u3002\u8fd9\u79cd\u6269\u5145\u4e0d\u662f\u7269\u7406\u4e0a\u6269\u5145\uff0c","``","MixDataLoader","``","\u4f1a\u6839\u636e","sampler","\u4e0d\u540c\u6765\u91cd\u91c7\u6837","dataset","\u5230\u6307\u5b9a\u7684\u6700\u5927\u957f\u5ea6","``","max_len","``","\u3002","*","ds_ratio","\u4e3a","``","Dict","[","str",",","float","]","``","\u65f6\uff0c","datasets","\u7c7b\u578b\u4e5f\u5fc5\u987b\u4e3a","``","Dict","[","str",",","DataSet","]","``",",","\u5176","key","\u4e00\u4e00\u5bf9\u5e94\u3002","ds_ratio","\u7684","value","\u662f\u4efb\u610f\u5927\u4e8e","0","\u7684\u6d6e\u70b9\u6570\uff0c","\u4ee3\u8868\u7740","datasets","\u7684","value","\u6570\u636e\u8fdb\u884c\u6269\u5145\u6216\u8005\u7f29\u51cf\u7684\u500d\u6570\u3002"]
code: def __iter__(self):
      return super().__iter__()
  
file_path: fastNLP/fastNLP/core/dataloaders/torch_dataloader/mix_dataloader.py
imports: from typing import Optional, Callable, List, Union, Tuple, Dict, Sequence, Mapping
  import numpy
  from pkg_resources import parse_version
  from fastNLP.core.dataset import DataSet, Instance
  from fastNLP.core.samplers import PollingSampler, MixSequentialSampler, DopedSampler
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
  from fastNLP.core.collators import Collator
label_desc: Use image node_id 2 for calling the MixDataLoader obj's underlying member method code with example usage: obj.__iter__() and returns: super