code: def convert_sklearn_isolation_forest(operator, device, extra_config):
      """
      Converter for `sklearn.ensemble.IsolationForest`.
  
      Args:
          operator: An operator wrapping a tree (ensemble) isolation forest model
          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"
  
      tree_infos = operator.raw_operator.estimators_
      n_features = operator.raw_operator.n_features_in_
      # Following constants will be passed in the tree implementation to normalize the anomaly score.
      extra_config[constants.OFFSET] = operator.raw_operator.offset_
      if hasattr(operator.raw_operator, "threshold_"):
          extra_config[
              constants.IFOREST_THRESHOLD
          ] = operator.raw_operator.threshold_
      extra_config[
          constants.MAX_SAMPLES
      ] = operator.raw_operator.max_samples_
  
      # Predict in isolation forest sklearn implementation produce 2 classes: -1 (normal) & 1 (anomaly).
      classes = [-1, 1]
  
      tree_parameters, max_depth, tree_type = get_tree_params_and_type(
          tree_infos, _get_parameters_for_sklearn_iforest, extra_config
      )
  
      # Generate the tree implementation based on the selected strategy.
      if tree_type == TreeImpl.gemm:
          net_parameters = [
              get_parameters_for_gemm_common(
                  tree_param.lefts,
                  tree_param.rights,
                  tree_param.features,
                  tree_param.thresholds,
                  tree_param.values,
                  n_features,
              )
              for tree_param in tree_parameters
          ]
          return GEMMIsolationForestImpl(
              operator,
              net_parameters,
              n_features,
              classes,
              extra_config=extra_config,
          )
  
      net_parameters = [
          get_parameters_for_tree_trav_sklearn(
              tree_param.lefts,
              tree_param.rights,
              tree_param.features,
              tree_param.thresholds,
              tree_param.values,
              classes,
          )
          for tree_param in tree_parameters
      ]
      if tree_type == TreeImpl.tree_trav:
          return TreeTraversalIsolationForestImpl(
              operator,
              net_parameters,
              max_depth,
              n_features,
              classes,
              extra_config=extra_config,
          )
      else:  # Remaining possible case: tree_type == TreeImpl.perf_tree_trav
          return PerfectTreeTraversalIsolationForestImpl(
              operator,
              net_parameters,
              max_depth,
              n_features,
              classes,
              extra_config=extra_config,
          )
  
imports: import numpy
  from onnxconverter_common.registration import register_converter
  from ..None import constants
  from .._tree_commons import get_parameters_for_sklearn_common, get_parameters_for_tree_trav_sklearn, get_tree_params_and_type, get_parameters_for_gemm_common
  from .._tree_implementations import TreeImpl, GEMMTreeImpl, TreeTraversalTreeImpl, PerfectTreeTraversalTreeImpl
label_desc: Use image node_id 4 for calling a global function with example usage: convert_sklearn_isolation_forest(operator, device, extra_config) and returns: GEMMIsolationForestImpl, TreeTraversalIsolationForestImpl, PerfectTreeTraversalIsolationForestImpl