code: def paddle2torch(
      batch: Any, device: str = None, no_gradient: bool = None
  ) -> Any:
      """
      递归地将输入中包含的 :class:`paddle.Tensor` 转换为 :class:`torch.Tensor` 。
  
      :param batch: 包含 :class:`paddle.Tensor` 类型的数据集合；
      :param device: 是否将转换后的张量迁移到特定设备上。为 ``None``时，和输入保持一致；
      :param no_gradient: 是否保留原张量的梯度。为 ``None`` 时，新的张量与输入张量保持一致；
          为 ``True`` 时，不保留梯度；为 ``False`` 时，保留梯度；
      :return: 转换后的数据；
      """
  
      return apply_to_collection(
          batch,
          dtype=paddle.Tensor,
          function=_paddle2torch,
          device=device,
          no_gradient=no_gradient,
      )
  
file_path: fastNLP/fastNLP/modules/mix_modules/utils.py
imports: from typing import Any, Optional, Union
  import numpy
  from fastNLP.core.utils import paddle_to, apply_to_collection
  from fastNLP.core.log import logger
  from fastNLP.envs.imports import _NEED_IMPORT_JITTOR, _NEED_IMPORT_TORCH, _NEED_IMPORT_PADDLE
label_desc: Use image node_id 6 for calling a global function with example usage: paddle2torch(batch, device, no_gradient) and returns: apply_to_collection