code: def _convert_common(
      model, backend, test_input=None, device="cpu", extra_config={}
  ):
      """
      A common function called by convert(...) and convert_batch(...) below.
      """
      assert model is not None
  
      # We destroy extra_config during conversion, we create a copy here.
      extra_config = deepcopy(extra_config)
  
      # Set some default configurations.
      # Add test input as extra configuration for conversion.
      if (
          test_input is not None
          and constants.TEST_INPUT not in extra_config
          and (is_spark_dataframe(test_input) or len(test_input) > 0)
      ):
          extra_config[constants.TEST_INPUT] = test_input
      # By default we return the converted model wrapped into a `hummingbird.ml._container.SklearnContainer` object.
      if constants.CONTAINER not in extra_config:
          extra_config[constants.CONTAINER] = True
      # By default we set num of intra-op parallelism to be the number of physical cores available
      if constants.N_THREADS not in extra_config:
          extra_config[constants.N_THREADS] = psutil.cpu_count(
              logical=False
          )
  
      # Fix the test_input type
      if constants.TEST_INPUT in extra_config:
          if isinstance(extra_config[constants.TEST_INPUT], list):
              extra_config[constants.TEST_INPUT] = np.array(
                  extra_config[constants.TEST_INPUT]
              )
          elif isinstance(extra_config[constants.TEST_INPUT], tuple):
              # We are passing multiple datasets.
              assert all(
                  [
                      isinstance(input, np.ndarray)
                      for input in extra_config[constants.TEST_INPUT]
                  ]
              ), "When passing multiple inputs only ndarrays are supported."
              assert all(
                  [
                      len(input.shape) == 2
                      for input in extra_config[constants.TEST_INPUT]
                  ]
              )
              extra_config[constants.N_FEATURES] = sum(
                  [
                      input.shape[1]
                      for input in extra_config[constants.TEST_INPUT]
                  ]
              )
              extra_config[constants.N_INPUTS] = len(
                  extra_config[constants.TEST_INPUT]
              )
          elif pandas_installed() and is_pandas_dataframe(
              extra_config[constants.TEST_INPUT]
          ):
              # We split the input dataframe into columnar ndarrays
              extra_config[constants.N_INPUTS] = len(
                  extra_config[constants.TEST_INPUT].columns
              )
              extra_config[constants.N_FEATURES] = extra_config[
                  constants.N_INPUTS
              ]
              input_names = list(
                  extra_config[constants.TEST_INPUT].columns
              )
              splits = [
                  extra_config[constants.TEST_INPUT][input_names[idx]]
                  for idx in range(extra_config[constants.N_INPUTS])
              ]
              splits = [df.to_numpy().reshape(-1, 1) for df in splits]
              extra_config[constants.TEST_INPUT] = (
                  tuple(splits) if len(splits) > 1 else splits[0]
              )
              extra_config[constants.INPUT_NAMES] = input_names
          elif sparkml_installed() and is_spark_dataframe(
              extra_config[constants.TEST_INPUT]
          ):
              from pyspark.ml.linalg import (
                  DenseVector,
                  SparseVector,
                  VectorUDT,
              )
              from pyspark.sql.types import (
                  ArrayType,
                  FloatType,
                  DoubleType,
                  IntegerType,
                  LongType,
              )
  
              df = extra_config[constants.TEST_INPUT]
              input_names = [field.name for field in df.schema.fields]
              extra_config[constants.N_INPUTS] = len(input_names)
              extra_config[constants.N_FEATURES] = extra_config[
                  constants.N_INPUTS
              ]
  
              size = df.count()
              row_dict = df.take(1)[0].asDict()
              splits = []
              for field in df.schema.fields:
                  data_col = row_dict[field.name]
                  spark_dtype = type(field.dataType)
                  shape = 1
                  if spark_dtype in [DenseVector, VectorUDT]:
                      np_dtype = np.float64
                      shape = data_col.array.shape[0]
                  elif spark_dtype == SparseVector:
                      np_dtype = np.float64
                      shape = data_col.size
                  elif spark_dtype == ArrayType:
                      np_dtype = np.float64
                      shape = len(data_col)
                  elif spark_dtype == IntegerType:
                      np_dtype = np.int32
                  elif spark_dtype == FloatType:
                      np_dtype = np.float32
                  elif spark_dtype == DoubleType:
                      np_dtype = np.float64
                  elif spark_dtype == LongType:
                      np_dtype = np.int64
                  else:
                      raise ValueError(
                          "Unrecognized data type: {}".format(
                              spark_dtype
                          )
                      )
  
                  splits.append(np.zeros((size, shape), np_dtype))
  
              extra_config[constants.TEST_INPUT] = (
                  tuple(splits) if len(splits) > 1 else splits[0]
              )
              extra_config[constants.INPUT_NAMES] = input_names
  
          test_input = extra_config[constants.TEST_INPUT]
  
      # We do some normalization on backends.
      if not isinstance(backend, str):
          raise ValueError(
              "Backend must be a string: {}".format(backend)
          )
      backend_formatted = backend.lower()
      backend_formatted = backends[backend_formatted]
  
      # Check whether we actually support the backend.
      _supported_backend_check(backend_formatted, backend)
      _supported_backend_check_config(
          model, backend_formatted, extra_config
      )
  
      if type(model) in xgb_operator_list:
          return _convert_xgboost(
              model, backend_formatted, test_input, device, extra_config
          )
  
      if type(model) in lgbm_operator_list:
          return _convert_lightgbm(
              model, backend_formatted, test_input, device, extra_config
          )
  
      if _is_onnx_model(model):
          return _convert_onnxml(
              model, backend_formatted, test_input, device, extra_config
          )
  
      if _is_sparkml_model(model):
          return _convert_sparkml(
              model, backend_formatted, test_input, device, extra_config
          )
  
      return _convert_sklearn(
          model, backend_formatted, test_input, device, extra_config
      )
  
imports: from copy import deepcopy
  import psutil
  import numpy
  from .operator_converters import constants
  from ._parse import parse_sklearn_api_model, parse_onnx_api_model, parse_sparkml_api_model
  from ._topology import convert
  from ._utils import assert_torch_installed, assert_lightgbm_installed, assert_xgboost_installed, pandas_installed, sparkml_installed, is_pandas_dataframe, is_spark_dataframe, tvm_installed
  from .exceptions import MissingConverter, MissingBackend
  from .supported import backends
  from sklearn.utils import all_estimators
  from sklearn.utils.validation import check_is_fitted
  from .None import operator_converters
  from .supported import xgb_operator_list
  from .supported import lgbm_operator_list
label_desc: Use image node_id 10 for calling a global function with example usage: _convert_common(model, backend, test_input, device, extra_config) and returns: _convert_sklearn, _convert_xgboost, _convert_lightgbm, _convert_onnxml, _convert_sparkml