code: def _get_iforest_anomaly_score_per_node(
      children_left, children_right, n_node_samples
  ):
      """
      Get anomaly score per node in isolation forest, which is node depth + _average_path_length(n_node_samples). Will
      be used to replace "value" in each tree.
  
      Args:
          children_left: left children
          children_right: right children
          n_node_samples: number of samples per node
      """
      # Get depth per node.
      node_depth = np.zeros(shape=n_node_samples.shape, dtype=np.int64)
      stack = [(0, -1)]  # seed is the root node id and its parent depth
      while len(stack) > 0:
          node_id, parent_depth = stack.pop()
          node_depth[node_id] = parent_depth + 1
          if children_left[node_id] != children_right[node_id]:
              stack.append((children_left[node_id], parent_depth + 1))
              stack.append((children_right[node_id], parent_depth + 1))
      return _average_path_length(n_node_samples) + node_depth
  
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 2 for calling a global function with example usage: _get_iforest_anomaly_score_per_node(children_left, children_right, n_node_samples) and returns: unknown