docstr: 测试字典结构的迁移
docstr_tok: ["\u6d4b\u8bd5\u5b57\u5178\u7ed3\u6784\u7684\u8fc1\u79fb"]
code: def test_dict_transfer(self):
      """
      测试字典结构的迁移
      """
  
      paddle_dict = {
          "tensor": paddle.rand((3, 4)),
          "list": [paddle.rand((6, 4, 2)) for i in range(10)],
          "dict": {
              "list": [paddle.rand((6, 4, 2)) for i in range(10)],
              "tensor": paddle.rand((3, 4)),
          },
          "int": 2,
          "string": "test string",
      }
  
      res = paddle_move_data_to_device(paddle_dict, device="gpu:0")
      assert isinstance(res, dict)
      self.check_gpu(res["tensor"], 0)
      assert isinstance(res["list"], list)
      for t in res["list"]:
          self.check_gpu(t, 0)
      assert isinstance(res["int"], int)
      assert isinstance(res["string"], str)
      assert isinstance(res["dict"], dict)
      assert isinstance(res["dict"]["list"], list)
      for t in res["dict"]["list"]:
          self.check_gpu(t, 0)
      self.check_gpu(res["dict"]["tensor"], 0)
  
      res = paddle_move_data_to_device(paddle_dict, device="gpu:0")
      assert isinstance(res, dict)
      self.check_gpu(res["tensor"], 0)
      assert isinstance(res["list"], list)
      for t in res["list"]:
          self.check_gpu(t, 0)
      assert isinstance(res["int"], int)
      assert isinstance(res["string"], str)
      assert isinstance(res["dict"], dict)
      assert isinstance(res["dict"]["list"], list)
      for t in res["dict"]["list"]:
          self.check_gpu(t, 0)
      self.check_gpu(res["dict"]["tensor"], 0)
  
      res = paddle_move_data_to_device(paddle_dict, device="cpu")
      assert isinstance(res, dict)
      self.check_cpu(res["tensor"])
      assert isinstance(res["list"], list)
      for t in res["list"]:
          self.check_cpu(t)
      assert isinstance(res["int"], int)
      assert isinstance(res["string"], str)
      assert isinstance(res["dict"], dict)
      assert isinstance(res["dict"]["list"], list)
      for t in res["dict"]["list"]:
          self.check_cpu(t)
      self.check_cpu(res["dict"]["tensor"])
  
file_path: fastNLP/tests/core/utils/test_paddle_utils.py
imports: import os
  import pytest
  from fastNLP.core.utils.paddle_utils import _convert_data_device, paddle_to, paddle_move_data_to_device
  from fastNLP.envs.imports import _NEED_IMPORT_PADDLE
label_desc: Use image node_id 6 for calling the TestPaddleMoveDataToDevice obj's underlying member method code with example usage: obj.test_dict_transfer() without return types