class_docstr: !
  Integrate multiple model convertion tools, and provide convertion service for users.
  When user uploads a model to this server, convert model and upload the results to VDL Bos.
  When user downloads the model, we get the data from Bos and send it to client.
  Maybe users can download from bos directy if frontend can achieve it.
docstr: Convert paddle model to onnx model.
docstr_tok: ["Convert","paddle","model","to","onnx","model","."]
code: def paddle2onnx_convert(self, opset_version, deploy_backend):
      """
      Convert paddle model to onnx model.
      """
      model_handle = request.files["model"]
      params_handle = request.files["param"]
      model_data = model_handle.stream.read()
      param_data = params_handle.stream.read()
      result = {}
      # Do a simple data verification
      try:
          opset_version = int(opset_version)
      except Exception:
          opset_version = 11
  
      if deploy_backend not in ["onnxruntime", "tensorrt", "others"]:
          deploy_backend = "onnxruntime"
  
      # call paddle2onnx to convert models
      hl = hashlib.md5()
      hl.update(model_data + param_data)
      identity = hl.hexdigest()
      result["request_id"] = identity
  
      with tempfile.NamedTemporaryFile() as model_fp:
          with tempfile.NamedTemporaryFile() as param_fp:
              model_fp.write(model_data)
              param_fp.write(param_data)
              model_fp.flush()
              param_fp.flush()
              try:
                  onnx_model = paddle2onnx.export(
                      model_fp.name,
                      param_fp.name,
                      opset_version=opset_version,
                      deploy_backend=deploy_backend,
                  )
              except Exception as e:
                  raise RuntimeError(
                      "[Convertion error] {}.\n Please open an issue at "
                      "https://github.com/PaddlePaddle/Paddle2ONNX/issues to report your problem.".format(
                          e
                      )
                  )
              if not onnx_model:
                  raise RuntimeError(
                      "[Convertion error] Please check your input model and param files."
                  )
  
              # upload transformed model to vdl bos
              filename = "bos://{}/paddle2onnx/{}/model.onnx".format(
                  self.bucket_name, identity
              )
              model_encoded = None
              if onnx_model:
                  try:
                      self.bos_client.write(
                          filename, onnx_model, append=False
                      )
                  except Exception as e:
                      print(
                          "Exception: Write file {}/model.onnx to bos failed, due to {}".format(
                              identity, e
                          )
                      )
                  model_encoded = base64.b64encode(onnx_model).decode(
                      "utf-8"
                  )
      result["model"] = model_encoded
      print(len(model_encoded))
      return result
  
imports: import base64
  import hashlib
  import json
  import os
  import shutil
  import tempfile
  import paddle
  import paddle2onnx
  from flask import request
  from x2paddle.convert import onnx2paddle
  from .xarfile import archive
  from visualdl.io.bfile import BosFileSystem
  from visualdl.server.api import gen_result
  from visualdl.server.api import result
  from visualdl.utils.dir import X2PADDLE_CACHE_PATH
label_desc: Use image node_id 4 for calling the ModelConvertApi obj's underlying member method code with example usage: obj.paddle2onnx_convert(opset_version, deploy_backend) and returns: result