code: def _jittor2torch(
      jittor_var: "jittor.Var",
      device: Optional[Union[str, int]] = None,
      no_gradient: bool = None,
  ) -> "torch.Tensor":
      """
      将 :class:`jittor.Var` 转换为 :class:`torch.Tensor` 。
  
      :param jittor_var: 要转换的 **jittor** 变量；
      :param device: 是否将转换后的张量迁移到特定设备上，输入为 ``None`` 时，根据 ``jittor.flags.use_cuda`` 决定；
      :param no_gradient: 是否保留原张量的梯度。为``None``时，新的张量与输入张量保持一致；
          为 ``True`` 时，全部不保留梯度；为 ``False`` 时，全部保留梯度；
      :return: 转换后的 **torch** 张量；
      """
      # TODO: warning：无法保留梯度
      # jittor的grad可以通过callback进行传递
      # 如果outputs有_grad键，可以实现求导
      no_gradient = (
          not jittor_var.requires_grad
          if no_gradient is None
          else no_gradient
      )
      if no_gradient == False:
          logger.warning(
              "The result tensor will not keep gradients due to differences between jittor and pytorch."
          )
      jittor_numpy = jittor_var.numpy()
      if not np.issubdtype(jittor_numpy.dtype, np.inexact):
          no_gradient = True
  
      if device is None:
          # jittor的设备分配是自动的
          # 根据use_cuda判断
          if jittor.flags.use_cuda:
              device = "cuda:0"
          else:
              device = "cpu"
  
      torch_tensor = torch.tensor(
          jittor_numpy, requires_grad=not no_gradient, device=device
      )
  
      return torch_tensor
  
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 3 for calling a global function with example usage: _jittor2torch(jittor_var, device, no_gradient) and returns: torch_tensor