docstr: 将 tensor 转为 numpy 值， 主要是在 metric 计算中使用
  
  :param tensor: 传入的张量
docstr_tok: ["\u5c06","tensor","\u8f6c\u4e3a","numpy","\u503c\uff0c","\u4e3b\u8981\u662f\u5728","metric","\u8ba1\u7b97\u4e2d\u4f7f\u7528",":","param","tensor",":","\u4f20\u5165\u7684\u5f20\u91cf"]
code: def tensor2numpy(self, tensor) -> np.array:
      """
      将 tensor 转为 numpy 值， 主要是在 metric 计算中使用
  
      :param tensor: 传入的张量
      """
  
      if isinstance(tensor, torch.Tensor):
          return tensor.cpu().detach().numpy()
      elif isinstance(tensor, np.ndarray):
          return tensor
      elif isinstance(tensor, (float, int)):
          return tensor
      else:
          raise ValueError(
              f"tensor: {tensor} can not convert to ndarray!"
          )
  
file_path: fastNLP/fastNLP/core/metrics/backend/torch_backend/backend.py
imports: from typing import Any, List, Optional
  import numpy
  from fastNLP.core.metrics.backend import Backend
  from fastNLP.core.metrics.utils import AggregateMethodError
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
  from fastNLP.core.drivers.torch_driver.dist_utils import fastnlp_torch_all_gather
label_desc: Use image node_id 6 for calling the TorchBackend obj's underlying member method code with example usage: obj.tensor2numpy(tensor) and returns: tensor, tensor, tensor