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: 将 :class:`DataSet` 每个 ``instance`` 中为 ``field_name`` 的 field 传给函数 ``func``，并写入到 ``new_field_name``
  中。
  
  :param func: 对指定 field 进行处理的函数，注意其输入应为 ``instance`` 中名为 ``field_name`` 的 field 的内容，返回值将被
      写入至 ``new_field_name`` 中。
  :param field_name: 传入 ``func`` 的 field 名称；
  :param new_field_name: 函数执行结果写入的 ``field`` 名称。该函数会将 ``func`` 返回的内容放入到 ``new_field_name`` 对
      应的 ``field`` 中，注意如果名称与已有的 field 相同则会进行覆盖。如果为 ``None`` 则不会覆盖和创建 field ；
  :param num_proc: 使用进程的数量。
  
      .. note::
      
          由于 ``python`` 语言的特性，设置该参数后会导致相应倍数的内存增长，这可能会对您程序的执行带来一定的影响。另外，使用多进程时，
          ``func`` 函数中的打印将不会输出。
  
  :param progress_desc: 如果不为 ``None``，则会显示当前正在处理的进度条的名称；
  :param progress_bar: 显示进度条的方式，支持 ``["rich", "tqdm", None]``。
  :return: 从函数 ``func`` 中得到的返回值；
docstr_tok: ["\u5c06",":","class",":","`","DataSet","`","\u6bcf\u4e2a","``","instance","``","\u4e2d\u4e3a","``","field_name","``","\u7684","field","\u4f20\u7ed9\u51fd\u6570","``","func","``","\uff0c\u5e76\u5199\u5165\u5230","``","new_field_name","``","\u4e2d\u3002",":","param","func",":","\u5bf9\u6307\u5b9a","field","\u8fdb\u884c\u5904\u7406\u7684\u51fd\u6570\uff0c\u6ce8\u610f\u5176\u8f93\u5165\u5e94\u4e3a","``","instance","``","\u4e2d\u540d\u4e3a","``","field_name","``","\u7684","field","\u7684\u5185\u5bb9\uff0c\u8fd4\u56de\u503c\u5c06\u88ab","\u5199\u5165\u81f3","``","new_field_name","``","\u4e2d\u3002",":","param","field_name",":","\u4f20\u5165","``","func","``","\u7684","field","\u540d\u79f0\uff1b",":","param","new_field_name",":","\u51fd\u6570\u6267\u884c\u7ed3\u679c\u5199\u5165\u7684","``","field","``","\u540d\u79f0\u3002\u8be5\u51fd\u6570\u4f1a\u5c06","``","func","``","\u8fd4\u56de\u7684\u5185\u5bb9\u653e\u5165\u5230","``","new_field_name","``","\u5bf9","\u5e94\u7684","``","field","``","\u4e2d\uff0c\u6ce8\u610f\u5982\u679c\u540d\u79f0\u4e0e\u5df2\u6709\u7684","field","\u76f8\u540c\u5219\u4f1a\u8fdb\u884c\u8986\u76d6\u3002\u5982\u679c\u4e3a","``","None","``","\u5219\u4e0d\u4f1a\u8986\u76d6\u548c\u521b\u5efa","field","\uff1b",":","param","num_proc",":","\u4f7f\u7528\u8fdb\u7a0b\u7684\u6570\u91cf\u3002","..","note",":",":","\u7531\u4e8e","``","python","``","\u8bed\u8a00\u7684\u7279\u6027\uff0c\u8bbe\u7f6e\u8be5\u53c2\u6570\u540e\u4f1a\u5bfc\u81f4\u76f8\u5e94\u500d\u6570\u7684\u5185\u5b58\u589e\u957f\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bf9\u60a8\u7a0b\u5e8f\u7684\u6267\u884c\u5e26\u6765\u4e00\u5b9a\u7684\u5f71\u54cd\u3002\u53e6\u5916\uff0c\u4f7f\u7528\u591a\u8fdb\u7a0b\u65f6\uff0c","``","func","``","\u51fd\u6570\u4e2d\u7684\u6253\u5370\u5c06\u4e0d\u4f1a\u8f93\u51fa\u3002",":","param","progress_desc",":","\u5982\u679c\u4e0d\u4e3a","``","None","``","\uff0c\u5219\u4f1a\u663e\u793a\u5f53\u524d\u6b63\u5728\u5904\u7406\u7684\u8fdb\u5ea6\u6761\u7684\u540d\u79f0\uff1b",":","param","progress_bar",":","\u663e\u793a\u8fdb\u5ea6\u6761\u7684\u65b9\u5f0f\uff0c\u652f\u6301","``","[","``","rich","''",",","``","tqdm","''",",","None","]","``","\u3002",":","return",":","\u4ece\u51fd\u6570","``","func","``","\u4e2d\u5f97\u5230\u7684\u8fd4\u56de\u503c\uff1b"]
code: def apply_field(
      self,
      func: Callable,
      field_name: str = None,
      new_field_name: str = None,
      num_proc: int = 0,
      progress_desc: str = None,
      progress_bar: str = "rich",
  ):
      r"""
      将 :class:`DataSet` 每个 ``instance`` 中为 ``field_name`` 的 field 传给函数 ``func``，并写入到 ``new_field_name``
      中。
  
      :param func: 对指定 field 进行处理的函数，注意其输入应为 ``instance`` 中名为 ``field_name`` 的 field 的内容，返回值将被
          写入至 ``new_field_name`` 中。
      :param field_name: 传入 ``func`` 的 field 名称；
      :param new_field_name: 函数执行结果写入的 ``field`` 名称。该函数会将 ``func`` 返回的内容放入到 ``new_field_name`` 对
          应的 ``field`` 中，注意如果名称与已有的 field 相同则会进行覆盖。如果为 ``None`` 则不会覆盖和创建 field ；
      :param num_proc: 使用进程的数量。
  
          .. note::
  
              由于 ``python`` 语言的特性，设置该参数后会导致相应倍数的内存增长，这可能会对您程序的执行带来一定的影响。另外，使用多进程时，
              ``func`` 函数中的打印将不会输出。
  
      :param progress_desc: 如果不为 ``None``，则会显示当前正在处理的进度条的名称；
      :param progress_bar: 显示进度条的方式，支持 ``["rich", "tqdm", None]``。
      :return: 从函数 ``func`` 中得到的返回值；
      """
      assert len(self) != 0, "Null DataSet cannot use apply_field()."
      if not self.has_field(field_name=field_name):
          raise KeyError(
              "DataSet has no field named `{}`.".format(field_name)
          )
  
      try:
          results = self._apply_process(
              num_proc=num_proc,
              func=func,
              progress_bar=progress_bar,
              progress_desc=progress_desc,
              _apply_field=field_name,
          )
      except BaseException as e:
          raise e
  
      if new_field_name is not None:
          self.add_field(field_name=new_field_name, fields=results)
      return results
  
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 25 for calling the DataSet obj's underlying member method code with example usage: obj.apply_field(func, field_name, new_field_name, num_proc, progress_desc, progress_bar) and returns: results