class_docstr: 不需要初始化 ``backend`` 的 :class:`AutoBackend`，能够根据 :meth:`get_metric` 时候判断输入数据类型来选择 ``backend``。
class_docstr_tok: ["\u4e0d\u9700\u8981\u521d\u59cb\u5316","``","backend","``","\u7684",":","class",":","`","AutoBackend","`","\uff0c\u80fd\u591f\u6839\u636e",":","meth",":","`","get_metric","`","\u65f6\u5019\u5224\u65ad\u8f93\u5165\u6570\u636e\u7c7b\u578b\u6765\u9009\u62e9","``","backend","``","\u3002"]
docstr: 根据 args 参数类型来选择需要真正初始化的 backend
  
  :param args: args 参数， 可能为 ``'jittor'``, ``'torch'``, ``'paddle'``, ``'oneflow'``, ``'numpy'`` 类型， 能够检测并选择真正的 backend。
docstr_tok: ["\u6839\u636e","args","\u53c2\u6570\u7c7b\u578b\u6765\u9009\u62e9\u9700\u8981\u771f\u6b63\u521d\u59cb\u5316\u7684","backend",":","param","args",":","args","\u53c2\u6570\uff0c","\u53ef\u80fd\u4e3a","``","'jittor","'","``",",","``","'torch","'","``",",","``","'paddle","'","``",",","``","'oneflow","'","``",",","``","'numpy","'","``","\u7c7b\u578b\uff0c","\u80fd\u591f\u68c0\u6d4b\u5e76\u9009\u62e9\u771f\u6b63\u7684","backend\u3002"]
code: def choose_real_backend(self, args):
      """
      根据 args 参数类型来选择需要真正初始化的 backend
  
      :param args: args 参数， 可能为 ``'jittor'``, ``'torch'``, ``'paddle'``, ``'oneflow'``, ``'numpy'`` 类型， 能够检测并选择真正的 backend。
  
      """
      assert not self.is_specified(), (
          "This method should not be called after backend has been specified. "
          "This must be a bug, please report."
      )
      types = []
      for arg in args:
          types.append(str(type(arg)))
  
      torch_types = []
      jittor_types = []
      paddle_types = []
      for type_name in types:
          if "torch" in type_name:
              torch_types.append(type_name)
          if "paddle" in type_name:
              paddle_types.append(type_name)
          if "jittor" in type_name:
              jittor_types.append(type_name)
  
      # 根据 https://stackoverflow.com/a/3464154 ，可以通过这种方法实现切换成真实的 backend 上
      if (
          len(torch_types) > 0
          and len(jittor_types) == 0
          and len(paddle_types) == 0
      ):
          backend = "torch"
      elif (
          len(torch_types) == 0
          and len(jittor_types) > 0
          and len(paddle_types) == 0
      ):
          backend = "jittor"
      elif (
          len(torch_types) == 0
          and len(jittor_types) == 0
          and len(paddle_types) > 0
      ):
          backend = "paddle"
      elif (
          len(torch_types) == 0
          and len(jittor_types) == 0
          and len(paddle_types) == 0
      ):
          backend = None
          # 尝试通过 modules 的方式自动寻找
          find_backends = []
          for backend in SUPPORT_BACKENDS:
              if backend in sys.modules:
                  find_backends.append(backend)
          if len(find_backends) == 1:
              backend = find_backends[0]
              logger.debug(
                  f"Find backend:{backend} through sys.modules."
              )
          else:
              logger.debug(
                  f"Cannot find backend through sys.modules, since find:{find_backends}."
              )
      else:
          types = list(set(torch_types + jittor_types + paddle_types))
          raise RuntimeError(
              f"Mixture of tensor type:{types} have been accept, please manually set backend instead of "
              f"using backend=auto."
          )
  
      self._convert_backend(backend)
  
file_path: fastNLP/fastNLP/core/metrics/backend/auto_backend.py
imports: from typing import Union
  import sys
  from ....envs.imports import SUPPORT_BACKENDS
  from ...log import logger
  from .backend import Backend
  from .torch_backend.backend import TorchBackend
  from .paddle_backend.backend import PaddleBackend
  from .jittor_backend.backend import JittorBackend
  from .oneflow_backend.backend import OneflowBackend
label_desc: Use image node_id 3 for calling the AutoBackend obj's underlying member method code with example usage: obj.choose_real_backend(args) without return types