class_docstr: 将所有数据集当成一个混合大数据集来对待， 在 __getitem__() 能根据输入的 idx 来判断属于哪个小数据并返回其 ds_index
class_docstr_tok: ["\u5c06\u6240\u6709\u6570\u636e\u96c6\u5f53\u6210\u4e00\u4e2a\u6df7\u5408\u5927\u6570\u636e\u96c6\u6765\u5bf9\u5f85\uff0c","\u5728","__getitem__","(",")","\u80fd\u6839\u636e\u8f93\u5165\u7684","idx","\u6765\u5224\u65ad\u5c5e\u4e8e\u54ea\u4e2a\u5c0f\u6570\u636e\u5e76\u8fd4\u56de\u5176","ds_index"]
docstr: 根据index索引获取数据， 能够跟 idx 的范围定位属于哪个小数据并返回
  
  :param idx: 整数类型的index或者列表
  :return:
docstr_tok: ["\u6839\u636eindex\u7d22\u5f15\u83b7\u53d6\u6570\u636e\uff0c","\u80fd\u591f\u8ddf","idx","\u7684\u8303\u56f4\u5b9a\u4f4d\u5c5e\u4e8e\u54ea\u4e2a\u5c0f\u6570\u636e\u5e76\u8fd4\u56de",":","param","idx",":","\u6574\u6570\u7c7b\u578b\u7684index\u6216\u8005\u5217\u8868",":","return",":"]
code: def __getitem__(
      self, idx: Union[int, List[int]]
  ) -> Union[Tuple[Instance, int], Tuple[DataSet, int]]:
      """
      根据index索引获取数据， 能够跟 idx 的范围定位属于哪个小数据并返回
  
      :param idx: 整数类型的index或者列表
      :return:
      """
      if isinstance(idx, int):
          if idx >= self.lens[-1]:
              raise ValueError(f"idx: {idx} out of range")
          # 找到其属于哪个数据集，返回下标
          ds_index = np.searchsorted(self.lens, idx, side="right")
          if ds_index > 0:
              idx -= self.lens[ds_index - 1]
          return self.datasets[ds_index][idx], ds_index
      elif isinstance(idx, list):
          # 一般一个list列表只能是属于一种数据的，否则会报错
          dataset = DataSet()
          ds_index = 0
          for i in idx:
              assert isinstance(i, int), "Only int index allowed."
              instance, ds_index = self[i]
              dataset.append(instance)
          return dataset, ds_index
      else:
          raise KeyError(
              "Unrecognized type {} for idx in __getitem__ method".format(
                  type(idx)
              )
          )
  
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 _MixDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: self,  ds_index, dataset,  ds_index