class_docstr: 使用 JittorSingleDriver 测试基类的函数
class_docstr_tok: ["\u4f7f\u7528","JittorSingleDriver","\u6d4b\u8bd5\u57fa\u7c7b\u7684\u51fd\u6570"]
docstr: 测试 tensor_to_numeric 函数
docstr_tok: ["\u6d4b\u8bd5","tensor_to_numeric","\u51fd\u6570"]
code: def test_tensor_to_numeric(self):
      """
      测试 tensor_to_numeric 函数
      """
      # 单个张量
      tensor = jt.Var(3)
      res = JittorSingleDriver.tensor_to_numeric(tensor)
      assert res == 3
  
      tensor = jt.rand(3, 4)
      res = JittorSingleDriver.tensor_to_numeric(tensor)
      assert res == tensor.tolist()
  
      # 张量list
      tensor_list = [jt.rand(6, 4, 2) for i in range(10)]
      res = JittorSingleDriver.tensor_to_numeric(tensor_list)
      assert isinstance(res, list)
      tensor_list = [t.tolist() for t in tensor_list]
      assert res == tensor_list
  
      # 张量tuple
      tensor_tuple = tuple([jt.rand(6, 4, 2) for i in range(10)])
      res = JittorSingleDriver.tensor_to_numeric(tensor_tuple)
      assert isinstance(res, tuple)
      tensor_tuple = tuple([t.tolist() for t in tensor_tuple])
      assert res == tensor_tuple
  
      # 张量dict
      tensor_dict = {
          "tensor": jt.rand(3, 4),
          "list": [jt.rand(6, 4, 2) for i in range(10)],
          "dict": {
              "list": [jt.rand(6, 4, 2) for i in range(10)],
              "tensor": jt.rand(3, 4),
          },
          "int": 2,
          "string": "test string",
      }
  
      res = JittorSingleDriver.tensor_to_numeric(tensor_dict)
      assert isinstance(res, dict)
      assert res["tensor"] == tensor_dict["tensor"].tolist()
      assert isinstance(res["list"], list)
      for r, d in zip(res["list"], tensor_dict["list"]):
          assert r == d.tolist()
      assert isinstance(res["int"], int)
      assert isinstance(res["string"], str)
      assert isinstance(res["dict"], dict)
      assert isinstance(res["dict"]["list"], list)
      for r, d in zip(res["dict"]["list"], tensor_dict["dict"]["list"]):
          assert r == d.tolist()
      assert (
          res["dict"]["tensor"]
          == tensor_dict["dict"]["tensor"].tolist()
      )
  
imports: import pytest
  from copy import deepcopy
  from pathlib import Path
  from fastNLP.core.drivers.jittor_driver import JittorSingleDriver
  from fastNLP.core.samplers import ReproduceBatchSampler, RandomSampler
  from fastNLP.core.dataloaders import JittorDataLoader
  from tests.helpers.models.jittor_model import JittorNormalModel_Classification_1
  from tests.helpers.datasets.jittor_data import JittorNormalDataset, JittorNormalXYDataset
  from tests.helpers.datasets.torch_data import TorchNormalDataset
  from tests.helpers.models.torch_model import TorchNormalModel_Classification_1
  from fastNLP.envs.distributed import rank_zero_rm
  from fastNLP.envs.imports import _NEED_IMPORT_JITTOR, _NEED_IMPORT_TORCH
label_desc: Use image node_id 6 for calling the TestJittorDriverFunctions obj's underlying member method code with example usage: obj.test_tensor_to_numeric() without return types