class_docstr: fastNLP的数据容器。
  
  Example::
  
      from fastNLP.core.dataset import DataSet, Instance
      data = {'x': [[1, 0, 1], [0, 1, 1], 'y': [0, 1]}
      data1 = [Instance(x=[1,0,1],y=0), Instance(x=[0,1,1],y=1)]
      ds = DataSet(data)
      ds = DataSet(data1)
  
  fastNLP的 DataSet 是 key-value 存储形式， 目前支持两种初始化方式，输入 data 分别为 ``List[:class:`~fastNLP.core.dataset.Instance`]`` 和
  ``Dict[str, List[Any]]``。
  
      * 当 data 为 ``List[:class:`~fastNLP.core.dataset.Instance`]`` 时,  每个 ``Instance`` 的 field_name 需要保持一致。
        Instance 详见 :class:`~fastNLP.core.dataset.Instance` 。
      * 当 data 为 ``Dict[str, List[Any]]`` 时， 则每个 key 的 value 应该为等长的 list， 否则不同 field 的长度不一致。
  
  :param data: 初始化的内容，其只能为两种类型，分别为 ``List[:class:`~fastNLP.core.dataset.Instance`]`` 和
      ``Dict[str, List[Any]]``。
  
      * 当 data 为 ``List[:class:`~fastNLP.core.dataset.Instance`]`` 时,  每个 ``Instance`` 的 field_name 需要保持一致。
        Instance 详见 :class:`~fastNLP.core.dataset.Instance` 。
      * 当 data 为 ``Dict[str, List[Any]] 时， 则每个 key 的 value 应该为等长的 list， 否则不同 field 的长度不一致。
class_docstr_tok: ["fastNLP\u7684\u6570\u636e\u5bb9\u5668\u3002","Example",":",":","from","fastNLP.core.dataset","import","DataSet",",","Instance","data","=","{","'","x","'",":","[","[","1",",","0",",","1","]",",","[","0",",","1",",","1","]",",","'","y","'",":","[","0",",","1","]","}","data1","=","[","Instance","(","x=","[","1,0,1","]",",","y=0",")",",","Instance","(","x=","[","0,1,1","]",",","y=1",")","]","ds","=","DataSet","(","data",")","ds","=","DataSet","(","data1",")","fastNLP\u7684","DataSet","\u662f","key-value","\u5b58\u50a8\u5f62\u5f0f\uff0c","\u76ee\u524d\u652f\u6301\u4e24\u79cd\u521d\u59cb\u5316\u65b9\u5f0f\uff0c\u8f93\u5165","data","\u5206\u522b\u4e3a","``","List","[",":","class",":","`","~fastNLP.core.dataset.Instance","`","]","``","\u548c","``","Dict","[","str",",","List","[","Any","]","]","``","\u3002","*","\u5f53","data","\u4e3a","``","List","[",":","class",":","`","~fastNLP.core.dataset.Instance","`","]","``","\u65f6",",","\u6bcf\u4e2a","``","Instance","``","\u7684","field_name","\u9700\u8981\u4fdd\u6301\u4e00\u81f4\u3002","Instance","\u8be6\u89c1",":","class",":","`","~fastNLP.core.dataset.Instance","`","\u3002","*","\u5f53","data","\u4e3a","``","Dict","[","str",",","List","[","Any","]","]","``","\u65f6\uff0c","\u5219\u6bcf\u4e2a","key","\u7684","value","\u5e94\u8be5\u4e3a\u7b49\u957f\u7684","list\uff0c","\u5426\u5219\u4e0d\u540c","field","\u7684\u957f\u5ea6\u4e0d\u4e00\u81f4\u3002",":","param","data",":","\u521d\u59cb\u5316\u7684\u5185\u5bb9\uff0c\u5176\u53ea\u80fd\u4e3a\u4e24\u79cd\u7c7b\u578b\uff0c\u5206\u522b\u4e3a","``","List","[",":","class",":","`","~fastNLP.core.dataset.Instance","`","]","``","\u548c","``","Dict","[","str",",","List","[","Any","]","]","``","\u3002","*","\u5f53","data","\u4e3a","``","List","[",":","class",":","`","~fastNLP.core.dataset.Instance","`","]","``","\u65f6",",","\u6bcf\u4e2a","``","Instance","``","\u7684","field_name","\u9700\u8981\u4fdd\u6301\u4e00\u81f4\u3002","Instance","\u8be6\u89c1",":","class",":","`","~fastNLP.core.dataset.Instance","`","\u3002","*","\u5f53","data","\u4e3a","``","Dict","[","str",",","List","[","Any","]","]","\u65f6\uff0c","\u5219\u6bcf\u4e2a","key","\u7684","value","\u5e94\u8be5\u4e3a\u7b49\u957f\u7684","list\uff0c","\u5426\u5219\u4e0d\u540c","field","\u7684\u957f\u5ea6\u4e0d\u4e00\u81f4\u3002"]
docstr: 去 DataSet 的内容， 根据 idx 类型不同有不同的返回值。 包括四种类型 ``[int, slice, str, list]``
  
      * 当 idx 为 ``int`` 时， idx 的值不能超过 ``DataSet`` 的长度, 会返回一个 ``Instance``, 详见
      :class:`~fastNLP.core.dataset.Instance`
      * 当 idx 为 ``slice`` 时， 会根据 slice 的内容创建一个新的 DataSet，其包含 slice 所有内容并返回。
      * 当 idx 为 ``str`` 时， 该 idx 为 DataSet 的 field_name, 其会返回该 field_name 的所有内容， 为 list 类型。
      * 当 idx 为 ``list`` 时， 该 idx 的 list 内全为 int 数字， 其会取出所有内容组成一个新的 DataSet 返回。
  
  Example::
  
      from fastNLP.core.dataset import DataSet
  
      ds = DataSet({'x': [[1, 0, 1], [0, 1, 1] * 100, 'y': [0, 1] * 100})
      ins = ds[0]
      sub_ds = ds[0:100]
      sub_ds= ds[[1, 0, 3, 2, 1, 4]]
      field = ds['x']
  
  :param idx: 用户传入参数
  :return:
docstr_tok: ["\u53bb","DataSet","\u7684\u5185\u5bb9\uff0c","\u6839\u636e","idx","\u7c7b\u578b\u4e0d\u540c\u6709\u4e0d\u540c\u7684\u8fd4\u56de\u503c\u3002","\u5305\u62ec\u56db\u79cd\u7c7b\u578b","``","[","int",",","slice",",","str",",","list","]","``","*","\u5f53","idx","\u4e3a","``","int","``","\u65f6\uff0c","idx","\u7684\u503c\u4e0d\u80fd\u8d85\u8fc7","``","DataSet","``","\u7684\u957f\u5ea6",",","\u4f1a\u8fd4\u56de\u4e00\u4e2a","``","Instance","``",",","\u8be6\u89c1",":","class",":","`","~fastNLP.core.dataset.Instance","`","*","\u5f53","idx","\u4e3a","``","slice","``","\u65f6\uff0c","\u4f1a\u6839\u636e","slice","\u7684\u5185\u5bb9\u521b\u5efa\u4e00\u4e2a\u65b0\u7684","DataSet\uff0c\u5176\u5305\u542b","slice","\u6240\u6709\u5185\u5bb9\u5e76\u8fd4\u56de\u3002","*","\u5f53","idx","\u4e3a","``","str","``","\u65f6\uff0c","\u8be5","idx","\u4e3a","DataSet","\u7684","field_name",",","\u5176\u4f1a\u8fd4\u56de\u8be5","field_name","\u7684\u6240\u6709\u5185\u5bb9\uff0c","\u4e3a","list","\u7c7b\u578b\u3002","*","\u5f53","idx","\u4e3a","``","list","``","\u65f6\uff0c","\u8be5","idx","\u7684","list","\u5185\u5168\u4e3a","int","\u6570\u5b57\uff0c","\u5176\u4f1a\u53d6\u51fa\u6240\u6709\u5185\u5bb9\u7ec4\u6210\u4e00\u4e2a\u65b0\u7684","DataSet","\u8fd4\u56de\u3002","Example",":",":","from","fastNLP.core.dataset","import","DataSet","ds","=","DataSet","(","{","'","x","'",":","[","[","1",",","0",",","1","]",",","[","0",",","1",",","1","]","*","100",",","'","y","'",":","[","0",",","1","]","*","100","}",")","ins","=","ds","[","0","]","sub_ds","=","ds","[","0:100","]","sub_ds=","ds","[","[","1",",","0",",","3",",","2",",","1",",","4","]","]","field","=","ds","[","'","x","'","]",":","param","idx",":","\u7528\u6237\u4f20\u5165\u53c2\u6570",":","return",":"]
code: def __getitem__(self, idx: Union[int, slice, str, list]):
      r"""
      去 DataSet 的内容， 根据 idx 类型不同有不同的返回值。 包括四种类型 ``[int, slice, str, list]``
  
          * 当 idx 为 ``int`` 时， idx 的值不能超过 ``DataSet`` 的长度, 会返回一个 ``Instance``, 详见
          :class:`~fastNLP.core.dataset.Instance`
          * 当 idx 为 ``slice`` 时， 会根据 slice 的内容创建一个新的 DataSet，其包含 slice 所有内容并返回。
          * 当 idx 为 ``str`` 时， 该 idx 为 DataSet 的 field_name, 其会返回该 field_name 的所有内容， 为 list 类型。
          * 当 idx 为 ``list`` 时， 该 idx 的 list 内全为 int 数字， 其会取出所有内容组成一个新的 DataSet 返回。
  
      Example::
  
          from fastNLP.core.dataset import DataSet
  
          ds = DataSet({'x': [[1, 0, 1], [0, 1, 1] * 100, 'y': [0, 1] * 100})
          ins = ds[0]
          sub_ds = ds[0:100]
          sub_ds= ds[[1, 0, 3, 2, 1, 4]]
          field = ds['x']
  
      :param idx: 用户传入参数
      :return:
      """
      if isinstance(idx, int):
          return Instance(
              **{
                  name: self.field_arrays[name][idx]
                  for name in self.field_arrays
              }
          )
      elif isinstance(idx, slice):
          if idx.start is not None and (
              idx.start >= len(self) or idx.start <= -len(self)
          ):
              raise RuntimeError(
                  f"Start index {idx.start} out of range 0-{len(self) - 1}"
              )
          dataset = DataSet()
          for field_name, field in self.field_arrays.items():
              dataset.add_field(
                  field_name=field_name, fields=field.content[idx]
              )
          dataset._collator = deepcopy(self.collator)
          return dataset
      elif isinstance(idx, str):
          if idx not in self:
              raise KeyError(
                  "No such field called {} in DataSet.".format(idx)
              )
          return self.field_arrays[idx]
      elif isinstance(idx, list):
          dataset = DataSet()
          for i in idx:
              assert isinstance(i, int), "Only int index allowed."
              instance = self[i]
              dataset.append(instance)
          dataset._collator = deepcopy(self.collator)
          return dataset
      else:
          raise KeyError(
              "Unrecognized type {} for idx in __getitem__ method".format(
                  type(idx)
              )
          )
  
imports: import _pickle
  from copy import deepcopy
  from typing import Optional, List, Callable, Union, Dict, Any, Mapping
  from types import LambdaType
  import sys
  import time
  import numpy
  from .field import FieldArray
  from .instance import Instance
  from fastNLP.core.utils.utils import pretty_table_printer, deprecated
  from fastNLP.core.collators import Collator
  from fastNLP.core.utils.rich_progress import f_rich_progress, DummyFRichProgress
  from fastNLP.core.utils.tqdm_progress import f_tqdm_progress
  from ..log import logger
  from fastNLP.core.utils.dummy_class import DummyClass
  from ..utils.utils import _get_fun_msg
label_desc: Use image node_id 5 for calling the DataSet obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: Instance, dataset, self, dataset