docstr: Compile the trained model for faster inference.
  
  Parameters
  ----------
  model
      The native model that is expected to be compiled.
docstr_tok: ["Compile","the","trained","model","for","faster","inference",".","Parameters","--","--","--","--","--","model","The","native","model","that","is","expected","to","be","compiled","."]
code: def compile(model, path: str, input_types=None):
      """
      Compile the trained model for faster inference.
  
      Parameters
      ----------
      model
          The native model that is expected to be compiled.
      """
      if isinstance(model, TabularNeuralNetTorchOnnxTransformer):
          return model
      import skl2onnx
      from skl2onnx import convert_sklearn, update_registered_converter
      from skl2onnx.common.data_types import FloatTensorType
      from sklearn.pipeline import Pipeline
      from sklearn.preprocessing import QuantileTransformer
  
      from ..utils.categorical_encoders import (
          OneHotMergeRaresHandleUnknownEncoder,
          OrdinalMergeRaresHandleUnknownEncoder,
      )
  
      # BIG HACK!
      # It is required to take raw_name instead of onnx_name for inputs.
      # TODO: Remove this hack after upgrading skl2onnx to >1.13
      # See https://github.com/onnx/sklearn-onnx/pull/938
      if int(skl2onnx.__version__.split(".")[1]) <= 13:
          skl2onnx.common.utils.get_column_index = (
              skl2onnx_common_utils_get_column_index
          )
  
      update_registered_converter(
          QuantileTransformer,
          "SklearnQuantileTransformer",
          quantile_transformer_shape_calculator,
          quantile_transformer_converter,
      )
      update_registered_converter(
          OneHotMergeRaresHandleUnknownEncoder,
          "OneHotMergeRaresHandleUnknownEncoder",
          onehot_handle_unknown_transformer_shape_calculator,
          onehot_handle_unknown_transformer_converter,
      )
      update_registered_converter(
          OrdinalMergeRaresHandleUnknownEncoder,
          "OrdinalMergeRaresHandleUnknownEncoder",
          ordinal_handle_unknown_transformer_shape_calculator,
          ordinal_handle_unknown_transformer_converter,
      )
  
      if input_types is None or not isinstance(input_types[0], tuple):
          raise RuntimeError(
              "input_types argument should contain at least one tuple, e.g. [((1, 14), np.float32)]"
          )
      pipeline = Pipeline(
          steps=[
              ("processor", model[0]),
          ]
      )
  
      for idx, input_type in enumerate(input_types):
          input_types[idx] = (
              input_type[0],
              FloatTensorType(input_type[1]),
          )
  
      onnx_model = convert_sklearn(pipeline, initial_types=input_types)
  
      predictor = TabularNeuralNetTorchOnnxTransformer(model=onnx_model)
      TabularNeuralNetTorchOnnxCompiler.save(onnx_model, path)
      return predictor
  
imports: import os
  import numpy
label_desc: Use image node_id 2 for calling the TabularNeuralNetTorchOnnxCompiler obj's underlying member method code with example usage: obj.compile(model, path, input_types) and returns: predictor, model