code: def convert_sklearn_kernel_pca(operator, device, extra_config):
      """
      Converter for `sklearn.decomposition.KernelPCA`
  
      Args:
          operator: An operator wrapping a `sklearn.decomposition.KernelPCA` transformer
          device: String defining the type of device the converted operator should be run on
          extra_config: Extra configuration used to select the best conversion strategy
  
      Returns:
          A PyTorch model
      """
      assert operator is not None, "Cannot convert None operator"
  
      if operator.raw_operator.kernel in [
          "linear",
          "poly",
          "rbf",
          "sigmoid",
          "cosine",
          "precomputed",
      ]:
          kernel = operator.raw_operator.kernel
          degree = operator.raw_operator.degree
          sv = operator.raw_operator.X_fit_
          non_zeros = np.flatnonzero(operator.raw_operator.eigenvalues_)
          scaled_alphas = np.zeros_like(
              operator.raw_operator.eigenvectors_
          )
          scaled_alphas[
              :, non_zeros
          ] = operator.raw_operator.eigenvectors_[
              :, non_zeros
          ] / np.sqrt(
              operator.raw_operator.eigenvalues_[non_zeros]
          )
          return KernelPCA(
              operator,
              kernel,
              degree,
              sv,
              scaled_alphas,
              operator.raw_operator.gamma,
              operator.raw_operator.coef0,
              operator.raw_operator._centerer.K_fit_rows_,
              operator.raw_operator._centerer.K_fit_all_,
              device,
          )
      else:
          raise NotImplementedError(
              "Hummingbird does not currently support {} kernel for KernelPCA. The supported kernels are linear, poly, rbf, sigmoid, cosine, and precomputed.".format(
                  operator.raw_operator.kernel
              )
          )
  
file_path: hummingbird/hummingbird/ml/operator_converters/sklearn/decomposition.py
imports: import numpy
  from onnxconverter_common.registration import register_converter
  from .._decomposition_implementations import KernelPCA, Decomposition, CrossDecomposition
label_desc: Use image node_id 2 for calling a global function with example usage: convert_sklearn_kernel_pca(operator, device, extra_config) and returns: KernelPCA