code: def quantile_transformer_converter(scope, operator, container):
      from scipy.stats import norm
      from skl2onnx.algebra.onnx_ops import (
          OnnxAbs,
          OnnxArgMin,
          OnnxCast,
          OnnxConcat,
          OnnxGatherElements,
          OnnxMatMul,
          OnnxReshape,
          OnnxSplit,
          OnnxSub,
      )
      from skl2onnx.common.data_types import guess_numpy_type
  
      op = operator.raw_operator
      opv = container.target_opset
      out = operator.outputs
  
      # We retrieve the unique input.
      X = operator.inputs[0]
  
      # In most case, computation happen in floats.
      # But it might be with double. ONNX is very strict
      # about types, every constant should have the same
      # type as the input.
      dtype = guess_numpy_type(X.type)
      batch_size = X.type.shape[0]
      n_quantiles = op.n_quantiles_
  
      # We tell in ONNX language how to compute the unique output.
      # op_version=opv tells which opset is requested
      C = op.quantiles_.astype(dtype)
      if opv < 18:
          C_col = OnnxSplit(
              C,
              axis=1,
              output_names=[
                  f"C_col{x}" for x in range(op.n_features_in_)
              ],
              op_version=opv,
          )
      else:
          C_col = OnnxSplit(
              C,
              axis=1,
              num_outputs=C.shape[1],
              output_names=[
                  f"C_col{x}" for x in range(op.n_features_in_)
              ],
              op_version=opv,
          )
      C_col.add_to(scope, container)
      if opv < 18:
          X_col = OnnxSplit(
              X,
              axis=1,
              output_names=[
                  f"X_col{x}" for x in range(op.n_features_in_)
              ],
              op_version=opv,
          )
      else:
          X_col = OnnxSplit(
              X,
              axis=1,
              num_outputs=X.type.shape[1],
              output_names=[
                  f"X_col{x}" for x in range(op.n_features_in_)
              ],
              op_version=opv,
          )
      X_col.add_to(scope, container)
      Y_col = []
      for feature_idx in range(op.n_features_in_):
          # This implements
          # > X_col[isfinite_mask] = np.interp(X_col_finite, self.references_, quantiles)
          #
          # Specifically, for yi = np.interp(xi, x, y), we implement
          # > def nearest_interp(xi, x, y):
          # >     idx = np.abs(x - xi[:,None])
          # >     return y[idx.argmin(axis=1)]
          # See https://stackoverflow.com/questions/21002799/extraploation-with-nearest-method-in-python
          repeat = OnnxMatMul(
              OnnxReshape(
                  X_col.outputs[feature_idx],
                  np.array([batch_size, 1], dtype=np.int64),
                  op_version=opv,
              ),
              np.ones(shape=(1, n_quantiles)).astype(dtype),
          )
          sub = OnnxSub(
              repeat,
              OnnxReshape(
                  C_col.outputs[feature_idx],
                  np.array([1, n_quantiles], dtype=np.int64),
                  op_version=opv,
              ),
              op_version=opv,
              output_names=[f"sub_col{feature_idx}"],
          )
          idx = OnnxAbs(
              sub,
              op_version=opv,
              output_names=[f"idx_col{feature_idx}"],
          )
          argmin = OnnxArgMin(
              OnnxReshape(
                  idx,
                  np.array([batch_size, n_quantiles], dtype=np.int64),
                  op_version=opv,
              ),
              axis=1,
              op_version=opv,
              output_names=[f"argmin_col{feature_idx}"],
          )
          references = np.clip(
              norm.ppf(op.references_), -5.2, 5.2
          ).astype(dtype)
          cst = np.broadcast_to(references, (batch_size, n_quantiles))
          argmin_reshaped = OnnxReshape(
              argmin,
              np.array([batch_size, 1], dtype=np.int64),
              output_names=[f"reshape_col{feature_idx}"],
          )
          ref = OnnxGatherElements(
              cst,
              argmin_reshaped,
              axis=1,
              op_version=opv,
              output_names=[f"gathernd_col{feature_idx}"],
          )
          ref_reshape = OnnxReshape(
              ref,
              np.array([batch_size, 1], dtype=np.int64),
              output_names=[f"Y_col{feature_idx}"],
          )
          ref_cast = OnnxCast(
              ref_reshape,
              to=1,
              op_version=opv,
              output_names=[f"ref_cast{feature_idx}"],
          )
          Y_col.append(ref_cast)
      Y = OnnxConcat(
          *Y_col, axis=1, op_version=opv, output_names=out[:1]
      )
      Y.add_to(scope, container)
  
imports: import os
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: quantile_transformer_converter(scope, operator, container) without return types