code: def _multi_proc(ds, _apply_field, func, counter, queue):
      """
      对数据集进行处理封装函数，以便多进程使用
  
      :param ds: 实现了 __getitem__() 和 __len__() 的对象
      :param _apply_field: 需要处理数据集的 field_name
      :param func: 用户自定义的 func
      :param counter: 计数器
      :param queue: 多进程时，将结果输入到这个 queue 中
      :return:
      """
      idx = -1
      import contextlib
  
      null = DummyClass()
      with contextlib.redirect_stdout(null):  # 避免打印触发 rich 的锁
          logger.set_stdout(stdout="raw")
          results = []
          try:
              for idx, ins in enumerate(ds):
                  if _apply_field is not None:
                      res = func(ins[_apply_field])
                  else:
                      res = func(ins)
                  results.append(res)
                  with counter.get_lock():
                      counter.value += 1
          except BaseException as e:
              if idx != -1:
                  logger.error(
                      "Exception happens at the `{}`th instance.".format(
                          idx
                      )
                  )
              raise e
      queue.put(pickle.dumps(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 2 for calling a global function with example usage: _multi_proc(ds, _apply_field, func, counter, queue) without return types