code: def dataclass_to_dict(data: "dataclasses.dataclass") -> Dict:
      """
      将传入的 ``dataclass`` 实例转换为字典。
      """
      if not is_dataclass(data):
          raise TypeError(
              f"Parameter `data` can only be `dataclass` type instead of {type(data)}."
          )
      _dict = dict()
      for _key in data.__dataclass_fields__:
          _dict[_key] = getattr(data, _key)
      return _dict
  
imports: import functools
  import inspect
  from inspect import Parameter
  import dataclasses
  from dataclasses import is_dataclass
  from copy import deepcopy
  from collections import defaultdict, OrderedDict
  from typing import Callable, List, Any, Dict, AnyStr, Union, Mapping, Sequence
  from typing import Tuple, Optional
  from time import sleep
  import os
  from contextlib import contextmanager
  from functools import wraps
  from prettytable import PrettyTable
  from pathlib import Path
  from fastNLP.core.log import logger
label_desc: Use image node_id 7 for calling a global function with example usage: dataclass_to_dict(data) and returns: _dict