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: 将 AutoBackend 转换为合适的 Backend 对象
  
  :param backend: 传入的 backend 值。
  
      * 当 backend 为 ``'torch'`` 时， 选择 :class:`~fastNLP.core.metric.TorchBackend`
      * 当 backend 为 ``'paddle'` 时， 选择 :class:`~fastNLP.core.metric.PaddleBackend`
      * 当 backend 为 ``'jittor'`` 时， 选择 :class:`~fastNLP.core.metric.JittorBackend`
      * 当 backend 为 ``'oneflow'`` 时， 选择 :class:`~fastNLP.core.metric.OneflowBackend`
      * 当 backend 为 ``None`` 时， 直接初始化
docstr_tok: ["\u5c06","AutoBackend","\u8f6c\u6362\u4e3a\u5408\u9002\u7684","Backend","\u5bf9\u8c61",":","param","backend",":","\u4f20\u5165\u7684","backend","\u503c\u3002","*","\u5f53","backend","\u4e3a","``","'torch","'","``","\u65f6\uff0c","\u9009\u62e9",":","class",":","`","~fastNLP.core.metric.TorchBackend","`","*","\u5f53","backend","\u4e3a","``","'paddle","'","`","\u65f6\uff0c","\u9009\u62e9",":","class",":","`","~fastNLP.core.metric.PaddleBackend","`","*","\u5f53","backend","\u4e3a","``","'jittor","'","``","\u65f6\uff0c","\u9009\u62e9",":","class",":","`","~fastNLP.core.metric.JittorBackend","`","*","\u5f53","backend","\u4e3a","``","'oneflow","'","``","\u65f6\uff0c","\u9009\u62e9",":","class",":","`","~fastNLP.core.metric.OneflowBackend","`","*","\u5f53","backend","\u4e3a","``","None","``","\u65f6\uff0c","\u76f4\u63a5\u521d\u59cb\u5316"]
code: def _convert_backend(self, backend):
      """
      将 AutoBackend 转换为合适的 Backend 对象
  
      :param backend: 传入的 backend 值。
  
          * 当 backend 为 ``'torch'`` 时， 选择 :class:`~fastNLP.core.metric.TorchBackend`
          * 当 backend 为 ``'paddle'` 时， 选择 :class:`~fastNLP.core.metric.PaddleBackend`
          * 当 backend 为 ``'jittor'`` 时， 选择 :class:`~fastNLP.core.metric.JittorBackend`
          * 当 backend 为 ``'oneflow'`` 时， 选择 :class:`~fastNLP.core.metric.OneflowBackend`
          * 当 backend 为 ``None`` 时， 直接初始化
  
      """
      if isinstance(backend, Backend):
          self.__class__ = backend.__class__
      # 如果是str，直接选择就好了
      elif backend == "torch":
          self.__class__ = TorchBackend
      elif backend == "paddle":
          self.__class__ = PaddleBackend
      elif backend == "jittor":
          self.__class__ = JittorBackend
      elif backend == "oneflow":
          self.__class__ = OneflowBackend
      elif backend is None:
          # 不用做任何事情就可以初始化了
          pass
      else:
          raise RuntimeError(
              f"We did not support `{backend}` to be used as backend for now."
          )
      self._specified = True
  
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 2 for calling the AutoBackend obj's underlying member method code with example usage: obj._convert_backend(backend) without return types