code: def paddle_to(
      data: "paddle.Tensor",
      device: Union[
          str,
          int,
          "paddle.fluid.core_avx.Place",
          "paddle.CPUPlace",
          "paddle.CUDAPlace",
      ],
  ) -> "paddle.Tensor":
      """
      将 ``data`` 迁移到指定的 ``device`` 上。:class:`paddle.Tensor` 没有类似 :meth:`torch.Tensor.to` 的函数来迁移张量，
      因此该函数只是集成了 :func:`paddle.Tensor.cpu` 和 :func:`paddle.Tensor.cuda` 两个函数。
  
      :param data: 要迁移的张量；
      :param device: 目标设备，可以是 ``str`` 或 ``int`` 及 **paddle** 自己的 :class:`paddle.fluid.core_avx.Place`、
          :class:`paddle.CPUPlace` 和 :class:`paddle.CUDAPlace` 类型；
      :return: 迁移后的张量；
      """
      if isinstance(device, paddle.fluid.core_avx.Place):
          if device.is_cpu_place():
              return data.cpu()
          else:
              return data.cuda(device.gpu_device_id())
      elif isinstance(device, paddle.CPUPlace):
          return data.cpu()
      elif isinstance(device, paddle.CUDAPlace):
          return data.gpu(device.get_device_id())
      elif device == "cpu":
          return data.cpu()
      else:
          return data.cuda(get_paddle_device_id(device))
  
file_path: fastNLP/fastNLP/core/utils/paddle_utils.py
imports: import os
  import re
  from typing import Any, Optional, Union
  from fastNLP.envs.imports import _NEED_IMPORT_PADDLE
  from fastNLP.envs import FASTNLP_DISTRIBUTED_CHECK, FASTNLP_BACKEND_LAUNCH, USER_CUDA_VISIBLE_DEVICES
  from .utils import apply_to_collection
label_desc: Use image node_id 2 for calling a global function with example usage: paddle_to(data, device) and returns: data, data, data, data, data, data